SVN undo delete before commit

前端 未结 7 1335
离开以前
离开以前 2021-01-29 23:02

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

相关标签:
7条回答
  • 2021-01-29 23:13

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

    rm -r some_dir

    svn update some_dir_parent

    0 讨论(0)
  • 2021-01-29 23:14

    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.

    0 讨论(0)
  • 2021-01-29 23:16

    What worked for me is

    svn revert --depth infinity deletedDir
    
    0 讨论(0)
  • 2021-01-29 23:18

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

    0 讨论(0)
  • 2021-01-29 23:24

    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
    
    0 讨论(0)
  • 2021-01-29 23:25

    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.

    0 讨论(0)
提交回复
热议问题