Git Undo Branch Delete operation (git delete branch undo)

Source: Internet
Author: User

This is a two-way situation.

The first kind you've quit terminal

Git reflog See your last commit SHA1 value

<sha1>

You can create a branch based on your SHA1 value, and this commit you can choose to delete the commit of the branch operation SHA1

The second case does not exit terminal
user@MY-PC /C/MyRepo (master)$ git branch -D master2Deleted130d7ba).    ThisSHA1 we need to restore it!user@MY-PC /C/MyRepo (master)$ 130d7ba

When you delete a branch, git branch-d will have a SHA1 value behind it, so you can restore your branch with this SHA1 value.

This time input

git branch 你的分支名  SHA1值

Then you can restore the branch based on your SHA1, the name of the branch is "your branch name"

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Git Undo Branch Delete operation (git delete branch undo)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.