Using Versioning

SVN and Git are the main version tracking tools which are used within CERN. SVN is officially supported. Support for Git is available, but the majority of code bases are still using SVN rather than Git.

SVN Commands

SVN works by storing diffs of files for each commit/ revision of the code base. The standard practice for tools and code is to have at least two directories in the tree: trunk and tags. An additional directory titled branches can also be included.


trunk - Here is the main code development. One should not always assume this is working as developers are creating the code base here and may be debugging issues.
tags - Here is a released version of the code which is fixed in terms of the code content. It should be expected to compile without any issues.
branches - Often a copy of the trunk which is being build for a specific purpose without interfering with the primary trunk. Often it will be merged back with the trunk at a later date.


svn co svn+ssh://$CERN_USER@svn.cern.ch/reps/atlas-iconnell/ ./ - This will checkout (co) my svn area, if permitted. One would be able to update according to the SVN server at a later date and also commit changes.
svn export svn+ssh://$CERN_USER@svn.cern.ch/reps/atlas-iconnell/ ./ - This will export my svn area, if permitted. This is equivalent to downloading all the code without any SVN tracking information.
svn add [files] - Adds files to SVN to allow versioning to be tracked.
svn commit - This will upload all changes in the current working directory to the SVN server and upload any new files.
svn update - This will check the current working directory against the SVN server and download any changes, updating the files in the current working directory. Any local changes will be kept so long as they do not conflict with the code on the server. If there are conflicts in the code, SVN will ask you to intervene, either editting the code or forcing to keep one of the versions (local or server). This can be problematic as it can break the code if not carefully merged.

Git Commands

Git works in a very different way to SVN. It should be viewed as storing each commit as a snapshot of a much bigger picture. As such, one needs to only download the full trunk once. You can then build different snapshots with this, rather than having to go to the server and checkout a completely independent set of files for each tag.


git clone [git-repository] ./ - This is the equivalent of checking out. You create a clone of the complete Git tree to your local area.
git tags -l - This will list all the tags (ie snapshots) which have been created in the Git repository.
git checkout -b [tag or branch] - This will build a specific tag or branch which is available in the Git repository.
git add [files] - Add files to Git repository.
git commit -m "message" - This will commit your changes to the head of your Git repository. Note - This does not put them on the Git repository server.
git push origin [branch] - This will then push the changes from your head, to the Git repository into the branch specified. "Master" is the standard branch, equivalent to trunk.
git pull - Update your local Git repository.

A very good guide is available here.