Home > Development Tools > git > How to withdraw a newly deleted branch in git

How to withdraw a newly deleted branch in git

WBOY
Release: 2022-06-24 10:28:43
Original
4713 people have browsed it

How to retract the newly deleted branch in git: 1. Use the "git remote prune" command to view the deleted branch; 2. Use the "git reflog" command to find the "commit SHA" of the last commit record of the deleted branch. "value; 3. Use the "git checkout -b dev commit SHA value" command to restore the deleted branch.

How to withdraw a newly deleted branch in git

The operating environment of this article: Windows 10 system, Git version 2.30.0, Dell G3 computer.

How does git withdraw a newly deleted branch?

There are two possibilities for branch deletion, either by deleting it with a command, which can be seen with git log; or by deleting it in a browser When merging branches, check the option to delete the source branch after merging.

1, check the deleted branch

git remote prune --dry-run origin
Copy after login

The deleted branch is

How to withdraw a newly deleted branch in git

2, find the deleted branch Delete the commit SHA value of the last commit record of the branch

git reflog
Copy after login

The commit SHA value of the last commit is 5f8fe57

How to withdraw a newly deleted branch in git

3, restore the branch

Use command to restore;

git checkout -b dev 5f8fe57
Copy after login

Recommended learning: "Git Tutorial"

The above is the detailed content of How to withdraw a newly deleted branch in git. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
git
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template