Software Carpentry logo

Version Control

April 24, 2010: We are pleased to announce that Version 4 of this course is now under development. For updates and an early peek at the content, please check out the Software Carpentry blog at http://www.software-carpentry.org/blog/.

1) Introduction

2) You Can Skip This Lecture If...

3) Problem #1: Collaboration

4) Solution: Version Control

5) Problem #2: Undoing Changes

6) Solution: Version Control (Again)

7) Which Version Control System?

8) Basic Use

Name            Orbital Radius  Orbital Period  Mass            Radius
Io              421.6           1.769138        893.2           1821.6
Europa          670.9           3.551181        480.0           1560.8
Ganymede        1070.4          7.154553        1481.9          2631.2
Callisto        1882.7          16.689018       1075.9          2410.3
The Basic Edit/Update Cycle

Figure 6.3: The Basic Edit/Update Cycle

9) How To Do It

10) Resolving Conflicts

11) Example of Resolving

Name            Orbital Radius  Orbital Period  Mass            Radius
Io              421.6           1.769138        893.2           1821.6
Europa          670.9           3.551181        480.0           1560.8
Ganymede        1070.4          7.154553        1481.9          2631.2
Callisto        1882.7          16.689018       1075.9          2410.3
Amalthea        181.4           0.498179        0.075           131 x 73 x 67
Himalia         11460           250.5662        0.095           85
Elara           11740           259.6528        0.008           40
Name            Orbital Radius  Orbital Period  Mass            Radius
                (10**3 km)      (days)          (10**20 kg)     (km)
Io              421.6           1.769138        893.2           1821.6
Europa          670.9           3.551181        480.0           1560.8
Ganymede        1070.4          7.154553        1481.9          2631.2
Callisto        1882.7          16.689018       1075.9          2410.3
Amalthea        181.4           0.498179        0.075           131
Himalia         11460           250.5662        0.095           85
Elara           11740           259.6528        0.008           40
Pasiphae        23620           743.6           0.003           18
Sinope          23940           758.9           0.0008          14
Lysithea        11720           259.22          0.0008          12
Merging Conflicts

Figure 6.6: Merging Conflicts

12) Example of Resolving (continued)

Name            Orbital Radius  Orbital Period  Mass            Radius
                (10**3 km)      (days)          (10**20 kg)     (km)
Io              421.6           1.769138        893.2           1821.6
Europa          670.9           3.551181        480.0           1560.8
Ganymede        1070.4          7.154553        1481.9          2631.2
Callisto        1882.7          16.689018       1075.9          2410.3
<<<<<<< .mine
Amalthea        181.4           0.498179        0.075           131
Himalia         11460           250.5662        0.095           85
Elara           11740           259.6528        0.008           40
Pasiphae        23620           743.6           0.003           18
Sinope          23940           758.9           0.0008          14
Lysithea        11720           259.22          0.0008          12
=======
Amalthea        181.4           0.498179        0.075           131 x 73 x 67
Himalia         11460           250.5662        0.095           85
Elara           11740           259.6528        0.008           40
>>>>>>> .r152

13) Example of Resolving (continued)

14) Starvation

15) Binary Files

16) Reverting

17) Rolling Back

18) Creating and Checking Out

19) Subversion Command Reference

Name Purpose Example
svn add Add files and/or directories to version control. svn add newfile.c newdir
svn checkout Get a fresh working copy of a repository. svn checkout https://your.host.name/rotor/repo rotorproject
svn commit Send changes from working copy to repository (inverse of update). svn commit -m "Comment on the changes"
svn delete Delete files and/or directories from version control. svn delete oldfile.c
svn diff Shows changes for directories/files in a unified diff format. svn diff somefile.c
svn help Get help (in general, or for a particular command). svn help update
svn log Show history of recent changes. svn log --verbose *.c
svn merge Merge two different versions of a file into one. svn merge -r 18:16 spin.c
svn mkdir Create a new directory and put it under version control. svn mkdir newmodule
svn rename Rename a file or directory, keeping track of history. svn rename temp.txt release_notes.txt
svn revert Undo changes to working copy (i.e., resynchronize with repository). svn revert spin.h
svn status Show the status of files and directories in the working copy. svn status
svn update Bring changes from repository into working copy (inverse of commit). svn update

Table 6.1: Common Subversion Commands

20) Reading Subversion Output

$ svn status
- M jupiter/moons.txt
- C readme.txt
$ svn update
- A saturn/moons.txt
- U mars/mars.txt

21) Summary

22) SmartSVN: Setup

23) SmartSVN: Import into the Repository