Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How git restores deleted remote branches

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

This article mainly introduces the relevant knowledge of "how to restore deleted remote branches in git". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to restore deleted remote branches in git" can help you solve the problem.

Methods: 1, use reflog operation to find the last commitid, the syntax is "git reflog-date=iso"; 2, use checkout to cut out the branch and restore the deleted remote branch, the syntax is "git checkout-b branch name commitid".

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

How does git restore deleted remote branches

In practice, there must be times when I am not careful, for example, I delete the local dev branch, and the intellij idea prompts whether to delete the tracked branch as well. As a result, I accidentally delete the remote branch, and then my journey of redemption comes.

Check reflog and find the last commitid.

Git reflog-date=iso

Reflog means reference log, which refers to log to record the movement track of HEAD on each branch. The option-date=iso, indicates that it is displayed in a standard time format. Here you must ask, why not use git log? Git log is the commit log used to record the current branch. The branches have been deleted and the commit log can not be found.

Find the last commitid of the target branch

D:\ > git reflog-- date=iso287ba1b HEAD@ {2019-05-13 15:35:18 + 0800}: checkout: moving from dev to deploy528a169 HEAD@ {2019-05-13 09:23:58 + 0800}: commit: add ignore, .idea,*.iml,*.log

Cut out the branch

Git checkout-b recovery_branch_name commitid

After cutting out the branch, there is a branch locally, and then push to the remote warehouse is fine.

This is the end of git push origin recovery_branch_name 's introduction to "how git recovers deleted remote branches". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Tags: Branch knowledge practice method industry grammar affirmation difference practicality and then accidentally do not use journey that is warehouse content practicality that is meaning article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Information Microsoft MariaDB macOS