git reset --hard 回滚以后 以后怎么再回去?
PHP中文网
PHP中文网 2017-05-02 09:20:55
0
2
895

git reset --hard 回滚到之前的版本以后,怎么撤销这一步回滚操作?

PHP中文网
PHP中文网

认证0级讲师

reply all(2)
漂亮男人

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:

  1. 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

  2. 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.

Peter_Zhu
git stash save
git reflog 
git checkout
git 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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template