I thought that I'd write a quick list of SVN commands that are slightly less used than commit and update.
Revert a committed file back to the last committed version ("Updated" from revision 32 to 31):
nobody@cloberrella:/javaIDE/netbeans/MCRI$ svn update --revision PREV res/questions.xml
U res/questions.xml
Updated to revision 31.
Find out who the last person who committed to the repository was and other useful information:
nobody@cloberrella:/javaIDE/netbeans/MCRI$ svn info
Path: .
URL: http://www.minigeek.org/....
Repository Root: http://www.minigeek.org/.....
Repository UUID: 62118870-0c2c-0410-a716-9e7e50941db3
Revision: 32
Node Kind: directory
Schedule: normal
Last Changed Author: nobody
Last Changed Rev: 32
Last Changed Date: 2007-07-08 09:57:28 +1000 (Sun, 08 Jul 2007)
branching the codebase:
Steps
- Checkout the code and create a folder (I've called it branches)
- Add the folder to the SVN
- copy the base of the SVN to the branch
nobody@wernstrom:~/mcri/mcri$ mkdir branches
nobody@wernstrom:~/mcri/mcri$ svn add branches/
A branches
nobody@wernstrom:~/mcri/mcri$ svn -m "added branches" commit
Adding branches
Committed revision 44.
nobody@wernstrom:~/mcri/mcri$ svn copy -m 'added cleanup branch' \
> http://www.minigeek.org/svn/mcri/trunk \
> http://www.minigeek.org/svn/mcri/branches/cleanup
Committed revision 47.
Creating tags of the codebase:
SVN makes no distinction between tags and branches, it's entirely a procedural thing that means you shouldn't update tags.
nobody@wernstrom:~/mcri/mcri$ mkdir tags
nobody@wernstrom:~/mcri/mcri$ svn add tags
A tags
nobody@wernstrom:~/mcri/mcri$ svn -m "added tags directory" commit
Adding tags
Committed revision 45.
nobody@wernstrom:~/mcri/mcri$ svn copy -m 'tag release 1.0' \
> http://www.minigeek.org/svn/mcri/trunk \
> http://www.minigeek.org/svn/mcri/tags/release-1.0
Committed revision 47.
Moving tags
If you were so inclined (you made a mistake with tagging a release), you can move the tag by doing a:
nobody@cloberrella:~$ svn copy -m 'moved tag release 1.0' \
> http://www.minigeek.org/svn/mcri/trunk \
> http://www.minigeek.org/svn/mcri/tags/release-1.0
Committed revision 52.
http://gcc.gnu.org/wiki/SvnBranch
Merging a branch back into the trunk
If you want/need to merge the branch that you are currently working on back into the trunk, then there are a few simple steps to follow.
If you are trying to merge the branch with the trunk, you need to get a copy of the trunk first (I'm sure there's a way of avoiding this, but I don't know what it is - post a comment if you know).
Then find out when the branch was created, this can be done with the nifty stop-on-copy command to svn log:
nobody@cloberrella:~$ svn log --stop-on-copy \
> http://www.minigeek.org/svn/mcri/branches/cleanup
------------------------------------------------------------------------
r54 | nobody | 2007-07-12 08:47:40 +1000 (Thu, 12 Jul 2007) | 2 lines
This is only a test
------------------------------------------------------------------------
r53 | nobody | 2007-07-12 08:34:02 +1000 (Thu, 12 Jul 2007) | 3 lines
Committing the branch back to the main trunk.
------------------------------------------------------------------------
r47 | nobody | 2007-07-10 08:53:41 +1000 (Tue, 10 Jul 2007) | 1 line
added cleanup branch
------------------------------------------------------------------------
nobody@cloberrella:~$
So the cleanup branch was branched at revision 47 in this example. You can see the differences without applying your branch to the trunk using --dry-run with svn merge, but I haven't in this case:
nobody@cloberrella:~/mcri/cleanup$ svn merge -r 47:HEAD http://www.minigeek.org/svn/mcri/branches/cleanup
U dist/MCRI.jar
U dist/MCRI.jad
U nbproject/private/private.xml
U src/readFile/questionnaire.java
U res/questions.xml
nobody@cloberrella:~/mcri/cleanup$
http://svnbook.red-bean.com/en/1.1/ch04s03.html
And then it's a simple matter of committing the changes (once you're happy with them) back to the SVN:
nobody@cloberrella:~/mcri/cleanup$ svn commit
Sending dist/MCRI.jad
Sending dist/MCRI.jar
Sending nbproject/private/private.xml
Adding res/blah.txt
Sending res/questions.xml
Sending src/readFile/questionnaire.java
Transmitting file data ......
Committed revision 53.
nobody@cloberrella:~/mcri/cleanup$
If you get a conflict, you can resolve it by manually fixing it or reverting to the trunk version with a
nobody@cloberrella:~/mcri/trunk$ svn revert MCRI.jar
(see the red bean book for more information http://svnbook.red-bean.com/en/1.1/ch03s05.html)
You can then clean up by removing the branch:
nobody@cloberrella:~/mcri/trunk$ svn rm -m "remove cleanup branch" \
> http://www.minigeek.org/svn/mcri/branches/cleanup
Committed revision 56.
Popularity: 18% [?]


Latest Comments