Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to undo removal of a file in svn

Tags:

svn

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?

like image 606
Ivo Bosticky Avatar asked Jul 31 '09 00:07

Ivo Bosticky


4 Answers

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')

like image 181
Cebjyre Avatar answered Nov 03 '22 01:11

Cebjyre


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.

like image 25
Arkady Avatar answered Nov 03 '22 01:11

Arkady


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.

like image 29
Daniel A. White Avatar answered Nov 03 '22 02:11

Daniel A. White


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
like image 20
Andrew Moore Avatar answered Nov 03 '22 00:11

Andrew Moore