It can be restored through reflog, provided that the lost branch or commit information has not been cleared by git gc
Under normal circumstances, GC will keep those useless objects for a long time before clearing them
You can use git reflog show or git log -g command to see all operation logs
The recovery process is simple:
Use the git log -g command to find the commitid corresponding to the information that needs to be restored. You can identify it by the time and date of submission. Find the commitid corresponding to the commit before executing reset --hard
Create a new branch through git branch recover_branch commitid
In this way, the code up to commitid, various submission records and other information are restored to the recover_branch branch.
stash your current dirty content. Use reflog to find the commit you want to go back to, checkout it and then create a branch to merge with the original branch.
It can be restored through reflog, provided that the lost branch or commit information has not been cleared by git gc
Under normal circumstances, GC will keep those useless objects for a long time before clearing them
You can use git reflog show or git log -g command to see all operation logs
The recovery process is simple:
Use the git log -g command to find the commitid corresponding to the information that needs to be restored. You can identify it by the time and date of submission. Find the commitid corresponding to the commit before executing reset --hard
Create a new branch through git branch recover_branch commitid
In this way, the code up to commitid, various submission records and other information are restored to the recover_branch branch.
stash your current dirty content. Use reflog to find the commit you want to go back to, checkout it and then create a branch to merge with the original branch.