Git-压扁后恢复中间提交

待定

我已将多个提交压缩为一个提交。压榨之前的提交之一包括调试打印,而与之一起被压榨的后来提交则删除了这些打印。有什么办法可以恢复它们?

merlin2011

是。在壁球之前使用git reflog,然后git checkout使用commit hash。

这是事件序列的示例。

git init .
touch Foo1 Foo2 Foo3
git add Foo1
git commit -m 'Adding Foo1'
git add Foo2
git commit -m 'Adding Foo2'
git add Foo3
git commit -m 'Adding Foo3'
git log # Observe all three commits
git rebase -i --root # Squash commits

git reflog 
    87a5159 HEAD@{0}: rebase -i (finish): returning to refs/heads/master
    87a5159 HEAD@{1}: rebase -i (squash): Adding Foo1
    a0eecf4 HEAD@{2}: rebase -i (squash): # This is a combination of 2 commits.
    4142aa5 HEAD@{3}: rebase -i (pick): Adding Foo1
    85ad082 HEAD@{4}: rebase -i (pick): Adding Foo1
    cbc3a0c HEAD@{5}: rebase -i (start): checkout cbc3a0c02d1899dcfcc614afc07b3a5a502af56f
    71697f7 HEAD@{6}: commit: Adding Foo3

git checkout HEAD@{6} # get back original commits, with head detached.

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章