简体   繁体   中英

How do I revert back to a previous SVN commit?

Suppose I'm at revision 50. But, I want to revert back to revision 45, and commit back as the stable version.

How do I do that, in the most simple way?

  1. What if I want to do that with one file?
  2. What if I want to do that with the entire repository?

I'm not sure what you mean by "commit back as the stable version", but depending on what you're trying to accomplish I recommend:

svn update -r45
This will rebase your working copy at revision 45.

or:

svn merge -c -50,-49,-48,-47,-46
This will update (by reverse-merging) your working copy by removing all the changes between 45 and 50. Now if you make changes and commit, it will be like you have removed 46-50 from the repository and made the HEAD revision (51?) to be r45 + your change.

Reverse merge those revisions that you want to undo. This can be done on one or multiple files. By reverse merging, your working copy gets changed to the state without that revision, which you then can commit.

You can simply do an update to revision using

svn up -r 45

But this will not let you commit the changes as SVN needs you to update your working copy to HEAD before you can commit. What you can do instead is

svn merge -r HEAD:45 yourFile
svn ci yourFile -m "Reverting back to rev 45"

I think one simple way should be this:

  • checkout revision 45 to a temporary directory
  • copy one or alle files to your working directory
  • commit

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