git rebase后丢失本地commit记录

 

在git rebase操作时,存在冲突时,使用git rebase --abort处理后,结果发现commit的修改和记录都没有了。(使用git rebase --skip处理,也有导致commit消失不见得情况),就是使用git log看不到。

并不是真的在git中完全消失了。

这是可以使用reflog命令列出log 信息。 
reflog : reference logs

$ git reflog 
d185b35 HEAD@{0}: rebase finished: returning to refs/heads/passport
d185b35 HEAD@{1}: rebase: checkout origin/passport
4ab8e52 HEAD@{2}: checkout: moving from passport_email to passport
d185b35 HEAD@{3}: checkout: moving from passport to passport_email
4ab8e52 HEAD@{4}: checkout: moving from passprot_bak to passport
d185b35 HEAD@{5}: checkout: moving from passport to passprot_bak
4ab8e52 HEAD@{6}: checkout: moving from passprot_bak to passport
d185b35 HEAD@{7}: commit: 添加邮件发送处理操作
............

这里显示了commit 的sha, version, message,找到你消失的commit,然后可以使用这个‘消失的’commit重新建立一个branch.

$git checkout -b branch-bak [commit-sha]
然后可以出来冲突,再git add, git commit, git push等操作,把修改提交。
--------------------- 
ref:

https://blog.csdn.net/lxbwolf/article/details/52103974

https://blog.csdn.net/whereismatrix/article/details/50611706

你可能感兴趣的:(git)