回滚

Posted on Posted in 8.附录

回滚

使用版本日志对话框

如果想恢复某个版本或者版本范围的变更,最简单的方法是使用版本日志对话框。这种方法也可以用来撤销最近的若干次变更,把以前的某个版本变成最新版。

  1. 选中想要恢复变更的文件或者文件夹。如果想要恢复所有的变更,需要选中最顶层的文件夹。

  2. Select
    TortoiseSVN → Show Log to display a list of revisions. You may need to
    use Show All or Next 100 to show the revision(s) you are interested in.

  3. Select the revision you wish to revert. If you want to undo a range of revisions, select the first one and hold the Shift
    key while selecting the last one. Note that for multiple revisions, the
    range must be unbroken with no gaps. Right click on the selected
    revision(s), then select Context Menu → Revert changes from this
    revision.

  4. 如果想要把以前的某个版本变成最新版本,右键点击选中的版本(范围),然后选择右键菜单 → 恢复到此版本。就能够撤销被选中版本后面所有的变更。

工作副本已经恢复到了变更以前的状态。检查恢复后的结果,然后提交变更。

使用合并对话框

如果要撤销更大版本范围的变更,可以使用合并对话框。上一个方法在后台使用了合并的机制,在这个方法里我们直接使用合并功能。

  1. 在工作副本上选择TortoiseSVN → 合并。

  2. In
    the From:  field enter the full folder URL of the branch or tag
    containing the  changes you want to revert in your working copy. This
    should come up as  the default URL.

  3. 在起始版本文本框里输入当前工作副本的版本号。如果能够保证没有其他人会提交变更,可以使用最新版本。

  4. 确认使用“起始: ”的 URL检查框处于被选中的状态。

  5. In the To Revision field enter the revision number that you want to revert to, namely the one before the first revision to be reverted.

  6. 点击合并按钮完成合并。

工作副本已经恢复到了变更以前的状态。检查恢复后的结果,然后提交变更。

使用 svndumpfilter

因为TortoiseSVN绝不会丢弃数据,所以那些被回滚的版本仍然以中间版本的形式被保留在版本库里。只是最新版本已经回到了以前的状态。如果想让版本库里的某些版本彻底消失,擦去这些版本曾经存在过的所有痕迹,就必须采取更极端的手段。不推荐使用这种方法,除非有很好的理由。比如某人向一个公开的版本库里提交了一份机密文件。

The only way to remove data from the repository is to use the Subversion command line tool svnadmin. You can find a description of how this works in the Repository Maintenance.