Create New Repo
svnadmin create /home/data/svn/[dir-name] chown apache:developer -R /home/data/svn/[dir-name] chown 2770 /home/data/svn/[dir-name]
Import New Site
- ssh into server
- to import new site to the trunk,
svn import [your-site] file:///home/data/svn/[your-site-name] -m "[import comments]"
View Available Sites In Trunk
svn ls file:///home/svn/trunk/
Checking Out a Site
- Create a directory to checkout and use ‘svn co’
cd ~ mkdir [my-site] svn co file:///home/svn/trunk/[site-name] [my-site]
Updating a site
cd ~/[my-site] svn update
View SVN Log
cd ~/[my-site] svn log
svn status -u can predict conflicts Suppose you run svn update and you get the following result:
svn update U index.html G changed-b.html C rubbish-b.html Updated to revision 46.
- U – Updated: file contained no local changes, but was updated from changes from the repository
- G – Merged: file had local changes, but the changes from the repository didn’t overlap with the local changes.
- C – Conflict: changes from the server overlaps with your own and you need to manually choose between them.
For every conflicted file, Subversion places three additional files in your directory:
filename.ext.mine This is your file as it existed in your working copy before you updated your working copy. That is, without conflict markers. This file has your latest changes in it and nothing else. (If Subversion considers the file to be unmergable, then the .mine file isn’t created, since it would be identical to the working file).
filename.ext.r1 #old revision This is the file that was the BASE revision before you updated your working copy. That is, it is the file that you checked out before you made your latest edits.
filename.ext.r2 #new revision This is the file that your Subversion client just received from the server when you updated your working copy. This file corresponds to the HEAD revision of the repository.
The “<<<<<<<“, “=======” and “>>>>>>>>” signs are conflict markers. (You need to make sure you have removed these signs before you commit the file).
The following is an example of a conflicting file with Conflict Markers.
$ cat sandwich.txt Top piece of bread Mayonnaise Lettuce Tomato Provolone <<<<<<< .mine Salami Mortadella Prosciutto ======= Sauerkraut Grilled Chicken >>>>>>> .r2 Creole Mustard Bottom piece of bread >>>>>>>>
- The text between “<<<<<<< .mine” and “=======” is the original text, indicated by the .mine
<<<<<<< .mine Salami Mortadella Prosciutto =======
- The text between “=======” and “>>>>>>>>” is the new conflicting text, indicated by the .r2
You must run svn resolved when finished This removes the three temporary files and tells subversion the file is no longer in conflict.
Checking out an older Version of a file / directory
svn co -r 1204 file:///home/svn/trunk/[your-site-name]
to check out revision 1204 of that directory. Just change the revision number and the directory you want to check out and you should be good.
Undeleting a file / directory
Best way to do it is to cp an old version over the deleted version. In the directory of the deleted file, ie
svn cp -r 109 foo.bar foo.bar
- type ‘svn help’ on command line to see options.
- check files permissions if things aren’t working.
- Using tortoiseSVN is an alternative to command line.