Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How git restores deleted remote branches

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report