Subversion Tutorial

From Compute
Jump to navigationJump to search

Theory Group Subversion Repository at LBNL -- Tutorial

After you have applied for a subversion account and have changed your initial password, you are ready to work.

You may browse the repository from any webbrowser by visiting https://physics.lbl.gov/svn/REPONAME but this will not allow you to modify any files.

It is strongly recommended that you at least browse the first two chapters of the Subversion Book. It is an excellent reference. This is true even (especially??) if you are already familiar with CVS.

To work on the project you must create a local working copy of the repository, much like you would using CVS. You can do this using whatever subversion client you are accustomed to using. This tutorial will assume you are working with the command-line client. To create a local working copy, create a directory, enter that directory, and execute

svn co https://physics.lbl.gov/svn/REPONAME 

Now enter the REPONAME directory and start working. If you create new files or directories, you must tell subversion to add these to the repository. For example, to add the file Introduction.tex, first create the file, then execute

svn add Introduction.tex 

You may delete, copy or move files within the repository via

svn delete Introduction.tex 
svn copy Introduction.tex Introduction-revised.tex 
svn move Introduction.tex Introduction-obsolete.tex 

In subversion you will make frequent use of the status command, which shows differences between your working copy and the main repository.

svn status 

Or you can get even more information with

svn diff 

Your local copy may become out of sync with the main repository when your collaborators commit changes. You may pull those changes into your local working copy by

svn update 

You should always do an svn update before committing changes. Subversion attempts to be smart about resolving conflicts between the main repository and your local working copy. If a collaborator has modified a file that you have also modified, but those modifications do not collide, subversion will be able to merge them cleanly. If human input is required to resolve a conflict, subversion will indicate this to you during the svn update and ask for guidance. You commit your local changes to the main repository via

svn commit -m "Commit message" 

Until you have issued a svn commit no changes you have made to your local working copy will be reflected in the main repository. You do not need to specify the '-m' on the command line. If you don't, your subversion client will start an editor that will allow you to enter a commit message.

You can read the commit messages for the various versions with

svn log

Subversion has many other features to allow tagging and branching, to revert to old versions, and to associate special properties with files within the repository, but the above is pretty much all you need to know to get started.