站内公告:

我们的虚拟社区正式开通了

Main Menu

git merge后,想恢复之前版本步骤

作者 jvip_chen, 2022-11月-03 02:26 下午

« 上一篇主题 - 下一篇主题 »

jvip_chen

一共需要三个步骤:

第一步:git checkout到你想恢复的分支上

1.git checkout 分支名
第二步:git reflog查出要回退到merge之前的版本号

 git reflog
└──╼$git reflog
a88a5c89 (HEAD -> channel/pre) HEAD@{0}: pull: Merge made by the 'ort' strategy.
cf889952 (dev/swipe_auto) HEAD@{1}: reset: moving to cf889952
cf889952 (dev/swipe_auto) HEAD@{2}: reset: moving to cf889952
3e5a2166 HEAD@{3}: merge dev/swipe_auto: Merge made by the 'ort' strategy.
3a4a5248 HEAD@{4}: checkout: moving from dev/swipe_auto to channel/pre
cf889952 (dev/swipe_auto) HEAD@{5}: commit: 优化sql
8517922d HEAD@{6}: checkout: moving from channel/qa to dev/swipe_auto
81fcf05d (channel/qa) HEAD@{7}: merge dev/swipe_auto: Merge made by the 'ort' strategy.
7c8f5fda HEAD@{8}: pull: Fast-forward
a02ee7cd HEAD@{9}: checkout: moving from dev/swipe_auto to channel/qa
     

第三步:git reset --hard 版本号,就可以回到merge之前的代码状态了

git reset --hard a1d566d
└──╼$git reset --hard 524763dc0c96249cd207956d59ad6d1f07a6a1de
HEAD is now at 524763dc 增加二次打印
    成功了