Ivo Bosticky
Ivo Bosticky

Reputation: 6408

How to undo removal of a file in 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?

Upvotes: 7

Views: 2376

Answers (4)

Cebjyre
Cebjyre

Reputation: 6642

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

Upvotes: 3

Arkady
Arkady

Reputation: 15079

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.

Upvotes: 3

Andrew Moore
Andrew Moore

Reputation: 95474

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

Upvotes: 2

Daniel A. White
Daniel A. White

Reputation: 191058

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.

Upvotes: 2

Related Questions