早上在本身的一個版本代碼上編輯,提交commint,可是checkout到其餘分支再checkout回來發現該的東西不見了,git
幸虧terminal尚未關掉,回看日誌:flask
Warning: you are leaving 2 commits behind, not connected to
any of your branches:
****** update
****** 增長flask中間服務文件
If you want to keep them by creating a new branch, this may be a good time
to do so with:
git branch <new-branch-name> ******
this
而後就將剛剛修改的建立新分支就好,spa
git branch <new-branch-name> ******日誌
可是,若是當時終端關閉了或者其餘緣由沒有找到呢?terminal
其實,只要你commint了,git本地是保存了這個變化的,就是沒有一個分支連接到這種變化,能夠使用:it
git reflog show HEAD@{now} -10
****** HEAD@{Fri Jul 27 11:24:56 2018 +0800}: checkout: moving from ******
****** HEAD@{Fri Jul 27 11:19:43 2018 +0800}: checkout: moving from master to 1a
****** HEAD@{Fri Jul 27 11:17:55 2018 +0800}: checkout: moving from develope to master
****** HEAD@{Fri Jul 27 11:17:40 2018 +0800}: checkout: moving from****** to develope
****** HEAD@{Fri Jul 27 11:16:16 2018 +0800}: checkout: moving from master to 1a
****** HEAD@{Fri Jul 27 11:15:50 2018 +0800}: checkout: moving from****** to master
****** HEAD@{Fri Jul 27 11:12:54 2018 +0800}: commit: update
****** HEAD@{Fri Jul 27 10:36:07 2018 +0800}: commit: 增長flask中間服務文件
****** HEAD@{Thu Jul 26 16:34:14 2018 +0800}: checkout: moving from develope to 1a
****** HEAD@{Thu Jul 26 16:34:09 2018 +0800}: commit: update hello.py
ast
而後跟據當時的commit信息找到編號,再class
git branch <new-branch-name> ******date
可見,認真寫好每一個commint 信息是多重要!!!!!