Get the App
SLTechnology News&Howtos  ›  Development  › 

How does Git retrieve lost commit nodes or branches

Shulou Source: shulou.com Published: 2022-06-01 05:14:39 11月10日 Update

Editor to share with you Git how to find the lost commit nodes or branches, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Retrieve lost commit nodes or branches

For example, after rebase in the previous step, it is found that it does not meet expectations, how to recover? Accidentally delete a branch, how to find it?

The main idea is to find the hash value of the commit object you want to return, and then perform a git reset restore.

We know that the emergence of Git is to ensure that our operations are not lost as far as possible. In the internal principle of Git, we said that once git object is created, it cannot be changed, so as long as you find its corresponding hash value, you can get it back. But what about ref? We have also mentioned in the internal principle of Git that it is a mutable pointer. For example, if you submit a commit in master, the current master ref will point to the hash value of the new commit object. Reflog is to record the history of these variable pointers, which can be understood as the log of ref or version control.

The above is all the content of the article "how to retrieve lost commit nodes or branches by Git". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Branches nodes articles hashes content principles that is pointers versions variables controls not so much history most ideas pointing more for example knowledge industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Technology NVidia Shulou Tech Info Xiaomi