You have committed several times but in the wrong order. Please reorder your commits.
你提交過幾次,但是提交的順序錯了,請調(diào)整提交順序。
在第44關和第45關我們使用 git rebase -i
命令修改了歷史日志的提交說明、把多次提交合并成了一次,在本關,我們要用這個命令來調(diào)整提交順序。
先查一下提交日志:
$ git log --pretty=oneline
3baec3ba260f841e097675e4ae6661a86e3dba50 Second commit
a5f696b57d524c83b9fbb094b013590e4ff3d43d Third commit
19f3b096c2765ab79d9b07a5bed3a4ebb83ebf6a First commit
f0c159847ae93dabc8fd23766b40cf0cc21b315d Initial Setup
從上面的查詢結果看出,"Second commit" 和 "Third commit" 的次序顛倒了。我們找到最后一條日志的哈希值 "f0c159847ae93",然后輸入下面的命令:
$ git rebase -i f0c159847ae93
系統(tǒng)自動打開文本編輯器,顯示出了歷史日志:
pick 19f3b09 First commit
pick a5f696b Third commit
pick 3baec3b Second commit
把第2行和第3行的內(nèi)容調(diào)整一下順序,即這樣:
pick 19f3b09 First commit
pick 3baec3b Second commit
pick a5f696b Third commit
然后保存退出,系統(tǒng)就會按照調(diào)整過的順序重新執(zhí)行一遍提交操作。再查看日志,發(fā)現(xiàn)順序已經(jīng)調(diào)整好了。
$ git log --pretty=oneline
58fe3005755a19d18c017973517dfaca1b1ae648 Third commit
e0e8d4428578fb7b1284b1c7902e435e9bd571c4 Second commit
19f3b096c2765ab79d9b07a5bed3a4ebb83ebf6a First commit
f0c159847ae93dabc8fd23766b40cf0cc21b315d Initial Setup
第47關過關畫面如下:
http://wiki.jikexueyuan.com/project/githug-walkthrough/images/level-47-reorder.png" alt="第47關 reorder" />