10. 总结

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.

表 4.1. 分支与合并命令

动作 Command
创建一个分支或标签 svn copy URL1 URL2
切换工作副本到分支或标签 svn switch URL
将分支与主干同步 svn merge trunkURL; svn commit
参见合并历史或适当的修改集 svn mergeinfo SOURCE TARGET
合并分支到主干 svn merge --reintegrate branchURL; svn commit
复制特定的修改 svn merge -c REV URL; svn commit
合并一个范围的修改 svn merge -r REV1:REV2 URL; svn commit
让自动合并跳过一个修改 svn merge -c REV --record-only URL; svn commit
预览合并 svn merge URL --dry-run
丢弃合并结果 svn revert -R .
从历史复活某些事物 svn copy URL@REV localPATH
撤销已经提交的修改 svn merge -c -REV URL; svn commit
感知合并的检查历史 svn log -g; svn blame -g
从工作副本创建一个标签 svn copy . tagURL
重新整理分支或标签 svn move URL1 URL2
删除分支或标签 svn delete URL