Niklas Rosencrantz
Niklas Rosencrantz

Reputation: 26644

Back to previous revision of file in subversion

How do I go back to the previous revision of a file in subversion? This might be the second most normal backward operation so it should be easy so why is it not documented clearly? I've already did revert and I need to go back even more. Now if I go back to a spec revision it's not the same as going back to the previous version of the file since just going back a revision might be some other revision than the last changes of that file and the file might be unchanged. Do you know what command I'm looking for?

Upvotes: 1

Views: 695

Answers (2)

anotherdave
anotherdave

Reputation: 6754

  1. svn log [file]: Check what the last revision against this file is.
  2. svn merge -c -NNNN [file]: Take the changeset number from the log in step one & do a reverse merge, to revert the delta change of that revision.
  3. svn ci [file]: Update the changes made locally to the repository so that the HEAD revision also removes the delta change

Upvotes: 0

Wasim Karani
Wasim Karani

Reputation: 8886

If you at revision 2, and you want to revert a file to revision 1.

You do
svn merge -c -2 my.file,
OR
svn merge -r 43:4 my.file

and then do svn diff, it seems to show one revision before 1 (that is, 0);

Only when you do svn merge -c 1 myfile (without the -), it looks like myfile is reverted to rev 1.

Upvotes: 2

Related Questions