SVN undo delete before commit

被刻印的时光 ゝ 提交于 2019-12-03 00:30:09

问题


If you delete a directory from an SVN working copy, but haven't committed yet, it's not obvious how to get it back. Google even suggests "svn undo delete before commit" as a common query when you type "svn undo d", but the search results are unhelpful.

edit: I'd like a solution that works in subversion 1.4.4


回答1:


svn revert deletedDirectory

Here's the documentation for the svn revert command.


EDIT

If deletedDirectory was deleted using rmdir and not svn rm, you'll need to do

svn update deletedDirectory

instead.




回答2:


1) do

svn revert . --recursive

2) parse output for errors like

"Failed to revert 'dir1/dir2' -- try updating instead."

3) call svn up for each of error directories:

svn up dir1/dir2



回答3:


What worked for me is

svn revert --depth infinity deletedDir



回答4:


Do a (recursive) Revert operation from a level above the directory you deleted.




回答5:


To make it into a one liner you can try something like:

svn status | cut -d ' ' -f 8 | xargs svn revert



回答6:


The simplest solution I could find was to delete the parent directory from the working copy (with rm -rf, not svn delete), and then run svn update in the grandparent. Eg, if you deleted a/b/c, rm -rf a/b, cd a, svn up. That brings everything back. Of course, this is only a good solution if you have no other uncommitted changes in the parent directory that you want to keep.

Hopefully this page will be at the top of the results next time I google this question. It would be even better if someone suggested a cleaner method, of course.




回答7:


You could remove the folder and update the parent directory before committing:

rm -r some_dir

svn update some_dir_parent



来源:https://stackoverflow.com/questions/1786687/svn-undo-delete-before-commit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!