简体   繁体   English

如何撤消不在HEAD的SVN提交

[英]How to undo an svn commit that's not at HEAD

I have a commit that's not at head, though later commits didn't touch any files on top of it. 我的提交还没到头,尽管后来的提交并没有触及上面的任何文件。

Is there a way to remove this commit from the trunk? 有没有办法从中继删除此提交?

Thanks, 谢谢,

There's a few basic approaches depending on how important it is that the revision is erased from history: 根据从历史中删除修订的重要性,有几种基本方法:

  • Reverse the changes via svn merge , commit them, and move on 通过svn merge撤消更改,提交更改并继续
  • Dump the repository and edit out the changeset via some svn dump tools. 转储存储库,并通过某些svn转储工具编辑更改集。 svndumpfilter or SvnDumpTool might work. svndumpfilter或SvnDumpTool可能起作用。 A lot more effort, but might be worth it if the data commited was of the "burn before reading" type -- passwords, "top secret" files, etc. 需要付出更多的努力,但是如果提交的数据属于“读取前刻录”类型,例如密码,“最高机密”文件等,则可能值得。
  • Wait for svn obliterate to be implemented. 等待svn obliterate Don't hold your breath . 不要屏住呼吸

You can back out a change in Subversion -- even if it's not the head by using svn merge . 您可以撤消Subversion中的更改-通过使用svn merge即使不是最重要的更改。

Let's say you're at revision 100, but realized that a change in Revision 94 has an issue: 假设您的版本为100,但意识到版本94的更改存在问题:

$ svn up  # Make sure your working directory is up to date
$ svn st  # Make sure there are no pending changes.
$ svn merge -c -94 .  # Removes changes done in Revision #94.

Note the negative 94. The -c means change. 注意负数94。 -c表示更改。 With a negative revision number, it's the same as if you said: 版本号为负,与您说的相同:

$ svn merge -r 94;93 .

Note that if you're not removing the last change, you may have conflicts (you made a change in Revision #96 that was also changed in Revision #94). 请注意,如果您不删除最后一个更改,则可能会发生冲突(您在版本96中进行了更改,在版本94中也进行了更改)。 It is always recommended to have a clean working directory when you do anything with svn merge . 使用svn merge进行任何操作时,始终建议您拥有一个干净的工作目录。

You can also use the --dry-run parameter to see what would be changed before you actually do the reverse merge. 您还可以使用--dry-run参数在实际执行反向合并之前查看要更改的内容。 This will help you catch possible conflicts and make sure the files being changed are the ones you think need to be changed. 这将帮助您发现可能的冲突,并确保要更改的文件是您认为需要更改的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM