Need to restore a deleted branch in Subversion

前端 未结 7 585
悲&欢浪女
悲&欢浪女 2020-12-07 16:14

I have two working copies of a Subversion repository, one of the trunk, and one of a branch I created.

I accidentally deleted the branch in a repository browser. How

相关标签:
7条回答
  • 2020-12-07 16:55

    Alternatively, if it was a single commit that deleted the branch:

    Revert the commit and then commit

    svn merge -c -REV .
    svn commit -m "Reverting deletion of branch XYZ"
    
    0 讨论(0)
  • 2020-12-07 17:02

    I ran into the same problem and solved it this way in SmartSVN (Enterprise 6.0.2):

    • Open a view on the trunk/HEAD
    • Call menu Repository / Open in Repository Browser (the deleted branch is absent from the branches folder)
    • In the repository browser, call menu Repository / Show Revision...
    • Select the revision just before the deletion (the deleted branch reappears in the branches folder)
    • Right-click on the deleted branch, select Copy in the menu and enter the same path for the destination
    0 讨论(0)
  • 2020-12-07 17:04

    Assuming your last revision was 108:

    svn merge --revision 108:107
    svn diff 
    svn commit -m "Reverted revision 108"
    

    You can also add your source URL to the merge:

    svn merge --revision 108:107 http://svn/repo/
    

    Elsewhere on Stack Overflow: Undoing a commit in TortoiseSVN

    0 讨论(0)
  • 2020-12-07 17:07

    Use:

    svn cp [path to deleted branch]@[revision before delete] [new path]
    

    For example:

    svn cp svn://myrepo.com/svn/branches/2.0.5@1993 \
           svn://myrepo.com/svn/branches/2.0.5_restored
    

    Where 1993 is the revision before the delete...

    Here is some good documentation...

    There must be some way of escaping the @ symbol in the username...

    0 讨论(0)
  • 2020-12-07 17:07

    Here is a solution if you are using TortoiseSVN:

    1. In the repo browser, navigate to the parent folder of the folder you deleted (e.g. "branches").
    2. Right click on the folder and do a "Show Log."
    3. Find the revision where you deleted the specific branch folder.
    4. Select the revision immediately before that revision.
    5. Right click and choose "Browse Repository." You are now looking at the state of the repository at the point in time right before you deleted the branch.
    6. Find the branch folder that you deleted, select, right-click, and choose "Copy to..."
    7. You can now copy the deleted folder to either a new name or even the same name.
    0 讨论(0)
  • 2020-12-07 17:10

    This worked for me,

    svn cp --username your_user_name https://path_to_your_repo/branches/deleted_branch_name@last_revision_before_deletion https://path_to_your_repo/branches/new_name_for_branch

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