- Course Resources
- Hardware and Media
- Network and Wireless
- Offsite Access
- Web Development
Main navigation | Main content
When choosing a directory to store your SVN repository, you should make sure there is enough space to store all of the projects that you will have in your repository. In order to set up a simple SVN repository, go to the directory where you want to set up the SVN repository and follow the steps below. Please note that these instructions are going to be relative to where you are making changes. You will have to remember the location of the repository that you set up.
% mkdir <directory name>
% chmod 770 <directory name>
% chgrp <group_name> <directory_name>
% chmod g+s <directory_name>
% svnadmin create --fs-type fsfs <directory_name>
The recommended file structure for a SVN project is:
You will need to set up a temporary directory with this file structure.
% mkdir <project_name> % mkdir <project_name>/trunk % mkdir <project_name>/branches % mkdir <project_name>/tags
% chmod -R 770 my_project/ % chgrp -R <group_name> <project_name>/ % chmod -R g+s <project_name>/
If your unversioned project files are on a lab computer or on the same machine as the repository:
% svn import <project_name> file:///<path_to_repository>/<svn_project> -m "Initial import"
If you have problems executing the import statement as given above using the file notation, or if you are importing project files from a laptop or home computer:
% svn import <project_name> svn+ssh://<host_name>/<path_to_repository>/<svn_project> -m "Initial import"
Where <host_name> is the name of a lab computer in the domain where your project is located.
Now a list of the subversion root directory should look like this:
% svn list file:///<path_to_repository> <svn_project>
And a list of the project should look like this:
% svn list file:///<path_to_repository>/<svn_project> branches/ tags/ trunk/
Once you can successfully checkout a copy of your project, you can delete the old local directory with your original, unversioned project files.
% rm -rf <project_name>/
% svn co file:///<path_to_repository>/<project_name>/trunk/ <new_project_name>Where <new_project_name> is the name of the directory where you want the the files from the project, <project_name>, to be checkout.
% svn co svn+ssh//<host_name>/<path_to_repository>/<project_name>/trunk/ <new_project_name>Where <host_name> is a the name of a computer which is on the same domain as the repository that you are trying to check out.
To update your working copy with all of the changes that have been committed to the project repository:
% svn update
When you update a directory, everything under that directory will be recursively updated. If you want to update your entire working copy of a repository, you just need to a svn update in the root directory of your working copy. You can also update an individual file in your working copy:
% svn update <path_to_file>/<file_name>
To check the status of your working copy against the repository:
% svn status
There are several common statuses that file can have:
"M" - indicates that your copy of the file has been modified. "A" - indicates that you have added the file to subversion, but have not committed the change. "?" - indicates that Subversion doesn’t know about this file. "C" - indicates a file content conflict that Subversion cannot resolve.
When you commit any change, you will be prompted to add a message describing the changes that are being checked in.
% svn commit
% svn commit <file_name_1> <file_name_2> ...
% svn diff
% svn diff <path_to_file>/<file_name>
Sometimes Subversion can’t resolve differences between your working copy and the latest version in the repository. If you run y, Subversion will print out a “C” status for conflicted files.
When a conflict occurs, the following message will be printed out:
% Conflict discovered in '<file_name>'. Select: (p) postpone, (df) diff-full, (e) edit, (mc) mine-conflict, (tc) theirs-conflict, (s) show all options:
If you choose to postpone (p) the conflict, for each conflicted file, Subversion will create three new files -
You will need to figure out how to merge the versions manually within your working copy, then run:
% svn resolved <file_name>
Note: 'svn resolved' will remove the three files that Subversion created during the failed update. If you want to preserve any of these files, copy them to a different file name before you run 'svn resolved'. Once you have run 'svn resolved', you can re-run 'svn commit'.
If you need to, you can always delete your working copy of a file and do an svn update to check out the latest version of that file. Example:
% rm <path_to_working_copy>/<file_name> % svn update <path_to_working_copy>/<file_name>
This will restore <file_name> with a fresh copy from the repository.
% svn help
% svn help <svn_command>
If you have multiple people who want to work on a project you can send an email to operator [at] cs [dot] umn [dot] edu to get a group set up. You will need to include a name for the group in the email, this should be 8 characters or fewer, the names of everyone that needs to be added to the group, and the University Internet ID or CS username of each person that needs to be added to the group.
Once you have a group create, you will need to set the group for the svn repository. Go into the directory above the root directory of the svn repository that you want to share with the group and run the following command:
% chgrp -R <group_name> /<svn_root_directory>
Every time that you create a new project, you will have to make sure the correct group is set by running the same command on the new project directory.
This is a very minimal introduction to svn. There are a lot of great online resources that will help you really dig in and learn how to use it. Here are a couple to get your started: