Using Subversion for sharing and backing up files
Subversion is a system for maintaining a repository to store a set of files, e.g., your source code. The repository can be shared among multiple users. It is similar to dropbox, if you have used that, but can be used without dropbox on the university infrastructure and provide a richer capability to resolve conflicts if two people modify the same file in the source code in parallel, etc.
This document is written from the perspective of using subversion at the University of Michigan for student projects.
First login to login.itd.umich.edu. From a Linux (Mint) or Mac OS system, you can simply use from the terminal (don't type the "%" character. That represents the prompt from the command shell provided by the Terminal):
% ssh login.itd.umich.edu
Now, create a repository. We called it capstone182, but you can use any appropriate name.
% svnadmin create capstone182
Now, we need to make sure that all the collaborators have read/write access to the repository. But, others don't. Let's say that you have one collaborator whose user ID is "mypartner". To check the default permissions first, do the following:
% fs la capstone182
On my system, I get the following:
punchout% fs la capstone182 Access list for capstone182 is Normal rights: system:authuser rl system:anyuser rl aprakash rlidwka
The above basically says that the user "aprakash", which is me, has read (r), link (i), insert (i), delete (d), write (w), lock (k), and administrative (a) rights. But, others on the system only have read and link rights. We need to take away the rights of others and add in the rights to read/write for mypartner. To do that, you need to do the following:
% fs setacl -dir capstone182 -acl system:anyuser none % fs setacl -dir capstone182 -acl system:authuser none % fs setacl capstone182 -acl mypartner all
(If you have more than one collaborator, execute the3rd command for all collaborators. If you have no other collaborator and this is a private repository, skip the 3rd command.)
As an example, I shared the folder with a user burella below and then confirmed the final permissions:
punchout% fs setacl -dir capstone182 -acl system:anyuser none punchout% fs setacl -dir capstone182 -acl system:authuser none punchout% fs setacl -dir capstone182 -acl burrella all punchout% fs la capstone182 Access list for capstone182 is Normal rights: aprakash rlidwka burrella rlidwka
You have successfully created a repository. But, for everyone to share the repository, you will need to give them the path to the repository. To do that, do the following:
% cd capstone182 % pwd
Note the output from "pwd" command. For example, on my system, I get
The subversion "URL" that you will use to share the repository with others will be:
svn+ssh://<userid>@login.itd.umich.edu/<outout from pwd>
For me, the path is
For burrella, the path to the same repository would be:
Note that the <userid> is you or your partner's ID.
Checking out and putting files in the repository
Go to a Linux or Mac OS system on which you have your files that you want to share via the subversion repository. If you are on Windows, you can download TortoiseSVN client. The instructions here assume that you are a mac or linux system.
First checkout the repository that you created from the Terminal (this is one-time. After that, you will not need to remember the URL.) Both you and your partner should be able to do this.
% svn checkout <subersion url to the repository>
For example, for me, I do the following:
% svn checkout svn+ssh://email@example.com/afs/umich.edu/user/a/p/aprakash/capstone182
This should create a folder called "capstone182" on your system. The folder will be initially empty. Move the files that you want to share in that folder. As an example, we will simply go into that folder and create a test file with some content, such as today's date/time.
% cd capstone182 % date > testfile.txt
Now, to push the file to the repository, you do the following:
% svn add testfile.txt % svn commit -m ″added a file″
For your partner to pull the file(s) from the repository, he/she does the following in the capstone182 folder:
% svn update
The normal cycle for editing a file and pushing it to the repository is:
% svn update ... make changes to the files % svn commit -m ″a short message to document the changes″
If you add new files, just run
% svn add *
followed by a commit.
More details on subversion can be found at online tutorials. Some other useful subversion commands are:
Deleting a file from the repository and for everyone in the group:
% svn delete <filename>
To restore an accidentally deleted file, simply update your copy from the repository:
% svn update
To rename a file:
% svn move <oldname> <newname>
To make a copy:
% svn copy <filename> <copyoffilename>
Subversion permits both you and your partner to work in the repository simultaneously on your respective computers. Occasionally, you may get a conflict when you commit your changes. This would occur if both of you have version1 of a file, but then each of you made independent changes to the same file. Upon check in, subversion will attempt to resolve the conflict. But, if it cannot, it will ask you to manually resolve the conflict.
See this for how to resolve conflicts: http://www.cl.cam.ac.uk/local/web/subversion/linux/resolvingconflicts.html