开发者

Recover a folder or file in TortoiseSVN whilst also retaining all history

In revision 1 a folder existed. In revision 2 the folder was accidently deleted and the change committed.

We wish to roll back such that the folder is present, and retain its history.

In the TortoiseSVN docs it indicates 'how' in the section titled "Getting a deleted file or folder back".

To quote:

Getting a deleted file or folder back

If you have deleted a file or a folder and already committed that delete operation to the repository, then a normal TortoiseSVN -> Revert can't bring it back anymore. But the file or folder is not lost at all. If you know the revision the file or folder got deleted (if you don't, use the log dialog to find out) open the repository browser and switch to that revision. Then select the file or folder you deleted, right-click and select [Context Menu] -> [Copy to...] as the target for that copy operation select the path to your working copy.

A switch retrieves the file into my working copy as one would expect, however there is no "Copy to" option on the context menu when I right click this working copy. If I open the repos browser, there is a copy to option, but it seems this simply takes a copy of开发者_运维知识库 the file.

The solution I feel is to do a Branch/Tag, but if I try this from a prior revision to the same path in the repository SVN throws error that the path already exists.

Therefore, how do I recover a folder/file in TortoiseSVN whilst also retaining all history.

TortoiseSVN v1.6.8, Build 19260 - 32 Bit , Subversion 1.6.11,


Do a "reverse merge":

  1. Ensure that your working copy is updated to HEAD and completely clean (not strictly necessary, but always a good idea before trying to merge)
  2. Right click on the folder and select TortoiseSVN > Merge...
  3. Select "Merge a range of revisions" and hit "Next"
  4. The URL to merge from is the repo path for your current directory (ie. the one containing the deleted file)
  5. The revision range to merge is the revision in which you deleted the file (show log might help here)
  6. Be sure to select "Reverse merge"
  7. Hit "Next"
  8. All the default merge options should be sufficient, so hit "Merge"

The file should now be added and still retain all of its previous history.

Explanation:

This "rolls back" the revision containing the deletion, but adds the merge information to the directory properties. SVN can track the original file through this metadata. On the command line you would to do a backwards merge of the revision in which you deleted it:

svn merge -c -<revision-number> path/containing/file

Note the hyphen before the rev number (ie. a "negative" revision nunber).


What you describe with "Copy to" is only in the Repo-Browser is correct. That's exactly the way you should recover your file. On the other hand, what's wrong with copying ?


"Copy to" in the repository browser is correct. I think you missed the fact, that this is a svn copy that retains the history information. Exactly what you asked for.


I think you can use the "Branch/Tag..." option in the context menu to do this, only specifying a particular revision as the source and the trunk as the destination.

AFAIK, it's the equivalent of the svn copy command line.

You could also use svn copy from the command line as well...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜