Git undo local branch delete

后端 未结 8 1755
慢半拍i
慢半拍i 2020-11-29 14:52

I just deleted the wrong branch with some experimental changes I need with git branch -D branchName.

How do I recover the branch?

8条回答
  •  清酒与你
    2020-11-29 15:27

    If you just deleted the branch, you will see something like this in your terminal:

    Deleted branch branch_name(was e562d13)
    
    • where e562d13 is a unique ID (a.k.a. the "SHA" or "hash"), with this you can restore the deleted branch.

    To restore the branch, use:

    git checkout -b  
    

    for example:

    git checkout -b branch_name e562d13 
    

提交回复
热议问题