Quick Links:
svnadmin create /path/to/reposThen once the new repository is created, it is easy to check it out and then start adding files to it. First, for example, on the svn host computer:
svnadmin create ~/svnroot/teachingThen go to a remote computer and check out a copy with
svn co svn+ssh://svn.cvrti.utah.edu/Home/myusernameid/svnroot/teaching Teaching cd Teaching cp some_files . svn add files svn commit -m "adding new files"To create a repository that is to be shared by other users (with accounts on the same computer as the repository) there are some additional steps.
cd ~/svnroot
umask 002
svnadmin create ~/svnroot/afib-nih09
chgrp -R svn afib-nih09/
svn co. For more details, keep reading....
svn co svn+ssh://machine_name/dirname local_dirnameThis will place the files from the machine_name/dirname repository into the "local_dirname", a local directory that svn will create if necessary.
If you local username does not match the username on the svn server, it has to be passed with the checkout command, as in
svn co svn+ssh://username@machine_name/dirname local_dirnameSome examples:
cd ~/roblibs svn co svn+ssh://svn.sci.utah.edu/home/sci/macleod/svnroot/roblibs/trunk .will check out the roblibs main trunk and put it in the local (in this case ~/roblibs) directory.
The checkout commands
svn co https://gforge.sci.utah.edu/svn/map3d/trunk map3dor
svn co https://username@gforge.sci.utah.edu/svn/map3d/trunk map3ddo the same thing but from a different repository that does not require ssh access. Because this computer is a gforge server, security in this is handled differently.
cd svn co svn+ssh://svn.sci.utah.edu/home/sci/macleod/svnroot/roblibs/trunk/cutil mycutilwould check out the cutil librarym which is part of the roblibs repository, and place it in a separate directory called ~/mycutil.
svn co file:///Path/To/Repository/dirname local_dirname
This does the same as above but looks in the local computer for the repository according to the path specified, e.g.,
svn co file:///home/sci/macleod/svnroot/wwwwill check out my entire web site when logged into the svn host computer, in this case one of the SCI servers.
svn add filename/directory-nameadds files or directories. The directory must already exist and when added, it will (be default) add all the contents of the directory.
When adding a binary file, i.e., on that contains more than just plain text, an additional command can reduce the overhead of carrying out diff operations each time these files are updated:
svn add filename(s) svn propset svn:mime-type application/pdf filename(s)
To remove a file, both from your local directory and the repository, enter the following:
svn rm filename/directory-name
When done with adding, deleting, and moving, it is necessary to commit the changes with
svn commit -m "message_text"
svn statuswill return a list of files that have changed or are otherwise interesting. The meaning of the code letters to the left of each file are as follows:
svn status -uStands for --show-updates and will talk to the repository and show changes relative to it; otherwise, status only looks locally.
Unlike CVS, svn allows locking of files! The mechanism is simple and transparent, well, it is kind of simple and not very transparent at times.
To lock a file in a repository:
svn upcommand.
svn lock file_names -m "optional comment"
svn commit file_names -m "optional comment" svn unlock file_namesNote that this will unlock ALL files in the directory, not just the one(s) that have changed. Or so it sometimes work.
--no-unlockoption to the command:
svn commit file_names -m "optional comment" --no-unlock
svn unlock file_names
Any user trying to change the file will be blocked with an error message that sounds truly scary. To discover status of a file, use the following command:
svn status -u letters-chris.tex O * letters-chris.texand look for an "O" (stands for owned by Others) in the entry for any locked files. Your own locked files should have a "K", e.g., when I execute this command on my own files
svn -u status letters-rob.tex K 743 letters-rob.texTo see who has locked the file, use the info command
svn info file_names Lock Token: opaquelocktoken:4ca4b536-70fa-4902-9a7c-8f9a7422fd86 Lock Owner: macleod Lock Created: 2013-11-16 06:57:09 -0700 (Sat, 16 Nov 2013)
svn --force unlock file_names 'file_names' unlockedAt least this is how it is supposed to work--sometimes it does (-:
Note that locking is tied to a session, a single terminal window, so that if you change windows, you suddenly do not look like the owner of the files. If files start appearing in a status list marked with an "O" (instead of "K"), then it could be that you have locked them but you are not you any more! This is when forcing an unlock (and then relocking) is the valuable escape!
svn revert filenameto throw away all of your local changes.
svn resolved filenameThis removes any three temporary files and Subversion no longer considers the file to be in a state of conflict.
svn infowill return information about the repository of the project in the current directory, e.g.,
Path: . URL: https://code.sci.utah.edu/svn/map3d/trunk Repository Root: https://code.sci.utah.edu/svn/map3d Repository UUID: 76038eab-591d-0410-bf0b-a17c1341c730 Revision: 29 Node Kind: directory Schedule: normal Last Changed Author: macleod Last Changed Rev: 29 Last Changed Date: 2007-02-27 14:45:08 -0700 (Tue, 27 Feb 2007)
svn listwill make a simple list of the current repository. Note, you must first "cd" to the repository. A nicer, more detailed version of the output comes from this variation:
svn list -vIf you know the URL of your possible repository, there is this varation, in a few examples:
svn list -v svn+ssh://host.example.com/repos/project svn list https://host.example.com/repos/projectA specific example, to review the contents of the CIBC 2014 renewal repository.
svn list -v https://gforge.sci.utah.edu/svn/cibc14will list all the directories in the repository,
886 macleod Mar 13 05:30 ./ 2 macleod Jul 09 2014 Management/ 886 macleod Mar 13 05:30 Planning/ 884 macleod Feb 17 22:21 Proposal/ 885 macleod Mar 11 10:18 WWW/
svn list -v --depth infinity https://gforge.sci.utah.edu/svn/cibc14will list all the files in the entire repository.
svn lsprovides a listing of the contents of a repository, much like the same command works in Unix. Simply go to the directory that is under svn control and enter svn ls, e.g.,
cd ~/www/docs svn lsYou may be prompted one or more time for the password of the repository but eventually there will be a list of the files and directories as the level of the current working directory. To get a high level view of the repository, enter the following command:
svn ls full_repository_pathwhere full_repository_path is whatever you are using, e.g.,
svn ls file:///Home/macleod/svnroot/wwwThe "-v" option will add more detail to any svn ls command.
The command svnlook is what provides access to the database containing the repository files; otherwise, there is not real way to examine a repository, unlike the CVS repositories. For example, the command
svnlook tree ~/svnroot/www | morewill reveal the contents, down to the files, of the entire www repository in my svnroot area. The output is long, hence the more command.
svnlook tree ~/svnroot/roblibs | moredoes the same for another repository of mine that actually contains several pieces, including cutil, fids, and gfilelib. This repository also contains the full set of trunk, branches, and tags organization that is the standard svn way of doing things for code development.
svn: Working copy '/Users/macleod/www' lockedThen run the cleanup command but always FROM THE TOP LEVEL OF THE REPOSITORY!!!. In the case above, I went to the ~/www and ran the command, e.g.,
cd ~/www svn cleanupand it seemed to work.
You can hope you never have to do this but it can happen and the commands are not too awful.
Taking the contents of one repository and moving it another happens like this:
svnadmin dump my_repos > my_repos_fileAt the end of which there will be a new file names my_repos_file (can be any filename). Now move this file to the new place
svnadmin load --force-uuid my_new_repos < my_repos_file
To tell your local repository to point to the new place, requires the following command:
svn switch --relocate old_URL new_URLSo for a specific case of moving my tex directory, the commands looked like this on the old computer:
svnadmin dump ~/svnroot/tex > tex.dump scp tex.dump new_computer:svnroot/and then on the new computer
svnadmin load --force-uuid ~/svnroot/tex < tex.dumpand finally on my local working copy
svn switch --relocate svn+ssh://svn.cvrti.utah.edu/Home/macleod/svnroot/tex svn+ssh://svn.sci.utah.edu/home/sci/macleod/svnroot/texall written on the same line.