1. 程式人生 > >git rebase後丟失本地commit記錄

git rebase後丟失本地commit記錄

在git rebase操作時,存在衝突時,使用git rebase --abort處理後,結果發現commit的修改和記錄都沒有了。(使用git rebase --skip處理,也有導致commit消失不見得情況),就是使用git log看不到。

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

這是可以使用reflog命令列出log 資訊。  reflog : reference logs

$ git reflog  d185b35 [email protected]{0}: rebase finished: returning to refs/heads/passport d185b35 [email protected]

{1}: rebase: checkout origin/passport 4ab8e52 [email protected]{2}: checkout: moving from passport_email to passport d185b35 [email protected]{3}: checkout: moving from passport to passport_email 4ab8e52 [email protected]{4}: checkout: moving from passprot_bak to passport d185b35 [email protected]
{5}: checkout: moving from passport to passprot_bak 4ab8e52 [email protected]{6}: checkout: moving from passprot_bak to passport d185b35 [email protected]{7}: commit: 新增郵件傳送處理操作 ............ 這裡顯示了commit 的sha, version, message,找到你消失的commit,然後可以使用這個‘消失的’commit重新建立一個branch.

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