Course notes taken for CSCB07/CSC207 at UofT (Software Design).

Basic introduction to version control and how to use SVN.

Overview

Why not email code to each other?

What is version control?

Version control tracks files over a period of time (who wrote what and what your file looked like an hour ago etc.). It also automatically merges contributions.

It creates revisions, which keep track of the changing states of files over time and merge contributions of multiple developers.

Benifits of Version Control

Git was created by Linus Torvalds in 2005 for development of the Linux kernel, with other kernel developers contributing to its initial development. Its current maintainer since 2005 is Junio Hamano.

As with most other distributed version-control systems, and unlike most client–server systems, every Git directory on every computer is a full-fledged repository with complete history and full version-tracking abilities, independent of network access or a central server. (Wikipedia)

Enterprise version control, seems like it is used by gaming companies.

Targets towards small teams, this software is not supported by Microsoft anymore.

Quite widely used, built by Apache Foundation.

Client-Server Architecture

SVN uses client-server architecture. This architecture is very common among many programs.

Note Git is not client-server, it does not have a centralized server at all.

SVN client server

Use Subversion

Before doing anything, you must first checkout the repository:

svn checkout https://lecture1207.googlecode.com/svn/trunk/ lecture1207 --username [email protected]

Above command will checkout repository https://lecture1207.googlecode.com/svn/trunk/ to a folder called lecture1207 as user [email protected].

After creating a new file, you must add it to SVN tracking tree:

touch newfile.txt
svn add newfile.txt

Then you can commit using the following command:

svn commit -m "Add newfile.txt" newfile.txt

To fetch updates from server, use the command:

svn update

svn status

svn status command is used to check current repository status, it will give you the following output:

STATUS_CODE file_name1
...

STATUS_CODE can be one of the following:

svn log

svn log [PATH]

svn log URL[@REV] [PATH...]

Shows log messages from the repository. If no arguments are supplied, svn log shows the log messages for all files and directories inside (and including) the current working directory of your working copy. You can refine the results by specifying a path, one or more revisions, or any combination of the two. The default revision range for a local path is BASE:1.

Resolve Conflicts

Following are the instructions provided by the instructor, however it is outdated.

To discard my own change:

svn revert

To discard other person’s change:

cp someFile.mine.java someFile.java
svn resolved
svn commit -m “I accepted mine changes”

However, there is a new instruction: http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.resolve.html