开发者

svn cat after svn del

开发者 https://www.devze.com 2022-12-30 19:39 出处:网络
I have inadvertently svn-deleted a file with svn del --targets del.txt. Now, I\'d like to recover that file with svn cat myPreciousFile.txt@4130 > myPreciousFile.txt, but svn gives me a warning tha

I have inadvertently svn-deleted a file with svn del --targets del.txt. Now, I'd like to recover that file with svn cat myPreciousFile.txt@4130 > myPreciousFile.txt, but svn gives me a warning that myPreciousFile.txt is not under version control. A svn cat -r 4130 myPreciousFile.txt > myPreciousFile.txt didn't work, either.

Can someone please tell me how I'd go about recovering this file again?

EDIT

Ok, I have tri开发者_如何学Ced it with svn merge, but it still doesn't work. Here's what I did (file names altered to protect the guilty...):

f:\path\to\dev\dir> svn diff -r 4250:4251 --summarize
D      file_one.tyb
D      file_two.tyb
D      myPreciousFile.txt

I interpret this output as "myPreciousFile was deleted in revision 4251". So, I tried it with svn merge:

f:\path\to\dev\dir> svn merge-c -4251 myPreciousFile.txt

And svn still warns me about myPreciousFile.txt not being under version control. (Same error message btw with svn merge-c -4250 myPreciousFile.txt.


You must not restore file with cat.

The proper way of doing this is copy

svn copy http://server/full/path/to/myPreciousFile.txt@4130 .

after that commit current directory. with this solution you will keep the complete history of changings of that file.


svn merge -c -<revision where you deleted the file> .

So if the delete occurred during revision 4131, you would:

svn merge -c -4131 .
             ^ the negative on the revision is important

In response to the question edit:

You shouldn't specify the filename. Just do . and your file will be restored. Then svn revert the changes that you don't want back.


As others have suggested, you can do a reverse merge to get your file back. I suspect that your command is failing because you also specified the specific file you want to merge, and that file isn't under source control anymore. I can see two options for how to recover it.

Merge and revert

Reverse merge the whole commit, then revert the files you really did want to delete. Here's the example you gave:

f:\path\to\dev\dir> svn diff -r 4250:4251 --summarize
D      file_one.tyb
D      file_two.tyb
D      myPreciousFile.txt

Do the reverse merge:

f:\path\to\dev\dir> svn merge -c -4251

Then revert the two you really meant to delete:

f:\path\to\dev\dir> svn revert file_one.tyb
f:\path\to\dev\dir> svn revert file_two.tyb

Copy

Use the copy command suggested by zerkms to copy the specific file you want out of the repository history.

svn copy http://server/full/path/to/myPreciousFile.txt@4130 .
0

精彩评论

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

关注公众号