Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How git restores deleted branches

Shulou Source: shulou.com Published: 2022-06-01 04:34:57 10月03日 Update

This article mainly explains "how to restore deleted branches of git", the content of the explanation is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "how to restore deleted branches of git"!

Git method to restore deleted branches: 1, using the "git reflog" command to find the last submitted record of the deleted branch; 2, using the "git checkout-b dev to obtain the deleted SHA value" command to restore the deleted branch.

This article operating environment: Windows10 system, Git2.30.0 version, Dell G3 computer.

How does git restore deleted branches

There are two possibilities for branches to be deleted, either with the command, which can be seen with git log, or when the browser merges branches, check the option to delete the source branch after merging.

1. View the deleted branches

Git remote prune-dry-run origin

The branch that was deleted is dev

2. Find the commit SHA value of the last submitted record of the deleted branch

Git reflog

The last submitted commit SHA value is 5f8fe57

3, restore the branch

1) use command to restore

Git checkout-b dev 5f8fe57

2) create a new branch directly based on commit SHA on Gitlab to restore the deleted branch

Thank you for reading, the above is the content of "how to restore deleted branches of git". After the study of this article, I believe you have a deeper understanding of how to restore deleted branches of git, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Branches commands learning content or that is ideas situations articles methods time is in more browsers environments computers knowledge knowledge points articles systems Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Docker Microsoft Shulou Information vpn