Up: Version Control

Introduction

slide 01 Hello, and welcome to the first episode of the Software Carpentry lecture on version control. In this episode, we will explain what version control is, how it works, and why you should use it.
slide 02 Suppose Wolfman…
slide 03 …and Dracula…
slide 04 …are writing a paper together.
slide 05 They both want to edit the file at the same time.
slide 06 What should they do?
slide 07 They could take turns…
slide 08 …but then they’d each spend a lot of time waiting.
slide 09 Or, they could each work on their own copy at the same time…
slide 10 …and patch things up afterward.
slide 11 But stuff always winds up getting lost, overwitten, or duplicated.
slide 12 And nobody wants that.
slide 13 The right solution is to use a version control system.
slide 14 This keeps the master copy of the file…
slide 15 …in a repository located on a server—a computer that is never used directly by people, but only by the applications serving them.
slide 16 No-one ever edits the master copy directly.
slide 17 Instead, Wolfman and Dracula each have a working copy on their own computer. This lets them work independently, making whatever changes they want.
slide 18 As soon Wolfman is ready to share his changes, he commits them to the repository.
slide 19 Dracula can then update his working copy to get those changes.
slide 20 And of course, when Dracula finishes working on something, he can commit…
slide 21 …and then Wolfman can update.
slide 22 But what if Dracula and Wolfman make changes to the same part of their working copies?
slide 23 Old-fashioned version control systems prevented this from happening by locking the master copy.
slide 24 Only one person (or monster) could open the lock at a time. This guaranteed that two or more people could never accidentally make changes to the same file at the same time…
slide 25 …but once again, it meant that people had to take turns.
slide 26 Most of today’s version control systems use a different strategy. In these systems, nothing is ever locked—everyone is always allowed to edit their working copy.
slide 27 Sometimes, of course, people will make changes to the same part of the paper.
slide 28 If Wolfman updates the master copy first, his changes are simply copied to the repository.
slide 29 If Dracula now tries to commit something that would overwrite Wolfman’s changes…
slide 30 …the version control system stops him…
slide 31 …and marks the conflict.
slide 32 It’s up to Dracula to edit the file to resolve the conflict. He can accept what Wolfman did, replace it with his own work, or write something new that combines the two—it’s up to him.
slide 33 Once he has fixed things, he can go ahead and commit.
slide 34 Version control is better than mailing files back and forth for at least three reasons.
slide 35 First, it’s hard (but not impossible) to accidentally overlook or overwrite someone’s changes—the version control system highlights them for you automatically.
slide 36 Second, there are no arguments about whose copy is the most up to date—the master copy is.
slide 37 Third, nothing that is committed to version control is ever lost, which means it’s like having an “infinite undo” in your editor.
slide 38 This works because the version control system never overwrites the master copy in the repository.
slide 39 Instead, every time someone commits a new version…
slide 40 …it is saved on top of the previous one.
slide 41 Since all old versions are saved…
slide 42 …it’s always possible to go back in time to see exactly who wrote what on a particular day, or what version of a program was used to generate a particular set of results.
slide 43 Version control systems do have one important shortcoming.
slide 44 If you are working with plain text files…
slide 45 …it’s easy for the version control system to find and display differences, and to help you merge them.
slide 46 Unfortunately, images, MP3s, PDFs, or Microsoft Word or Excel files aren’t stored as text—they use specialized binary data formats.
slide 47 Most version control systems don’t know how to deal with these formats, so all they can say is, “These files differ.” The rest is up to you.
slide 48 Even with this limitation, version control is one of the most important concepts in this course. In the next episode, we’ll introduce you to one of the most popular free version control systems around.

  1. No comments yet.
  1. No trackbacks yet.