Summary

We covered a lot of ground in this chapter. We discussed the concepts of tags and branches and demonstrated how Subversion implements these concepts by copying directories with the svn copy command. We showed how to use svn merge to copy changes from one branch to another or roll back bad changes. We went over the use of svn switch to create mixed-location working copies. And we talked about how one might manage the organization and lifetimes of branches in a repository.

Remember the Subversion mantra: branches and tags are cheap. So don't be afraid to use them when needed!

As a helpful reminder of all the operations we discussed, here is handy reference table you can consult as you begin to make use of branches.

Table 4.1. Branching and merging commands

ActionCommand
Create a branch or tagsvn copy URL1 URL2
Switch a working copy to a branch or tagsvn switch URL
Synchronize a branch with trunksvn merge trunkURL; svn commit
See merge history or eligible changesetssvn mergeinfo target --from-source=URL
Merge a branch back into trunksvn merge --reintegrate branchURL; svn commit
Merge one specific changesvn merge -c REV URL; svn commit
Merge a range of changessvn merge -r REV1:REV2 URL; svn commit
Block a change from automatic mergingsvn merge -c REV --record-only URL; svn commit
Preview a mergesvn merge URL --dry-run
Abandon merge resultssvn revert -R .
Resurrect something from historysvn copy URL@REV localPATH
Undo a committed changesvn merge -c -REV URL; svn commit
Examine merge-sensitive historysvn log -g; svn blame -g
Create a tag from a working copysvn copy . tagURL
Rearrange a branch or tagsvn mv URL1 URL2
Remove a branch or tagsvn rm URL