User Tools

Site Tools


cluster:version_control

Version control

Subversion

One suggestion in Code and Data for the Social Sciences: A Practitioner’s Guide (by Matthew Gentzkow and Jesse M. Shapiro) is to use a version control system for maintaining code and instead of just your own files or those shared in Dropbox. It provides numerous benefits and only takes a small amount of time to learn. The basic model is that there is a “repository” stored on a server (e.g. the cluster) and multiple people “checkout” copies of the project, make changes, and “commit” new changes back to the repository. The most popular program is Subversion (svn)and is installed on the cluster.

Creating a svn repository

Here is a way to quickly create a repository on the cluster. Create a myproject folder on your computer with three subfolders: trunk/, branches/, tags/. Put all of project content under the trunk/ subfolder. Copy the myproject folder to the cluster. SSH into the cluster, then

$ mkdir svn/ (you only have to do this once)
$ cd svn/
$ svnadmin create myproject
$ svn import ~/myproject file:///home/myusername/svn/myproject  -m "initial import"

You can delete the ~/myproject as all the files have been imported into ~/svn/myproject.

Then follow the instructions at File access to give coauthor permission to ~/svn/myproject.

Checking out a working copy

On your work machine (personal computer or could even be the cluster again) you will checkout a copy of the project and begin working. The most popular svn client for windows is TortoiseSVN (for Mac try SCPlugin). Connections must be made using the 'svn+ssh' protocol, so see here for how to set stuff up (I don't think you need the Pageant step). (See also Public Key Authentication.) Once you're ready to checkout a working copy:

  1. Create a myproject folder
  2. R-click on the folder and choose SVN checkout
  3. As URL put svn+ssh://myusername@cluster.econ.umd.edu/home/myusername/svn/myproject/trunk (change the second 'myusername' to the repository's owner if that's not you).
  4. Make sure TortoiseSVN doesn't add another layer to the checkout folder (it might try to make it /local_path/myproject/myproject, remove the second one).

Resources

Git

Git is a distributed version control system, which allows for more flexibility but some more complications. If you have a project that can be completely public you can use the popular Github. If you want the sharing server on the cluster than you want a 'bare' repo 'git init –bare project1.git' (which will make the directory project1.git. Then you will need to USING GIT IS UNDER CONSTRUCTION.

Cloning

If you are on the cluster you can clone someone else's repository

git clone file:///home/repoowner/path_to_repo reponame

and if you are on another system

git clone ssh://myname@cluster.econ.umd.edu/home/repoowner/path_to_repo reponame

If you are using tortoisegit then you may have to put a colon between the host and the path (.edu:/home/).

cluster/version_control.txt · Last modified: 2018/10/02 14:06 by schroeder