tags:

views:

237

answers:

4

duplicate: What’s a simple way to undelete a file in subversion?


What is the best way to undo removal of a file and keep the file history.

I've removed a file by accident, and commited it along with other changes.

I can get an older revision of the file and add it to svn, but I think this approach will lose change history.

How do I keep the history?

+2  A: 

If you remove a file using TortiseSVN's delete menu command or svn rm, the history is still there. It is not lost unless you mess with the repository more deeply than that.

Daniel A. White
+1  A: 

Revert that file to an earlier revision.

In TortoiseSVN, the easiest way to do this via the Log window.

  • Right click on your working copy
  • Click on Show Log
  • Select the revision you deleted the file on
  • Right click on the deleted file in the bottom pane
  • Click on Revert changes from this revision
Andrew Moore
+3  A: 

I can get an older revision of the file and add it to svn, but I think this approach will lose change history

No, it won't. This is the right thing to do. The history will reflect the removal of the file, but also its addition in the subsequent revision. This is what history is -- a record of what happened.

scrible
It depends on how the older revision of the file is added - if Ivo just copied a version of the file from somewhere else and added it as a new file, then svn blame would treat every line as coming from that addition, rather than the original revision it was entered.
Cebjyre
+2  A: 

You could try a reverse merge, but if it's a single file, svn copy might be easier:

svn copy file:///var/svn/repos/test/far-away -r 6 near-here

(Search that page for 'recommended')

Cebjyre