简体   繁体   中英

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
  • Dump the repository and edit out the changeset via some svn dump tools. svndumpfilter or SvnDumpTool might work. 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. Don't hold your breath .

You can back out a change in Subversion -- even if it's not the head by using svn merge .

Let's say you're at revision 100, but realized that a change in Revision 94 has an issue:

$ 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. 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). It is always recommended to have a clean working directory when you do anything with svn merge .

You can also use the --dry-run parameter to see what would be changed before you actually do the reverse merge. This will help you catch possible conflicts and make sure the files being changed are the ones you think need to be changed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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