2
我使用git rebase --interactive
更新了一個分支上的四個線性提交。他們是:我的提交在交互式重新分配期間如何丟失?
small fixes to irrelevant files
FeedbackViewController tests
live feedback tests
poke build bot
我設法失去了標題爲「FeedbackViewController」的提交。現在,我只有:
small fixes to irrelevant files
live feedback tests
poke build bot
在哪裏我失去了這個承諾,我怎麼能找回來,在第三最古老的定位承諾? 下面是git reflog --date=relative
輸出:
b2681e4 [email protected]{21 seconds ago}: rebase -i (finish): returning to refs/heads/end
b2681e4 [email protected]{24 seconds ago}: checkout: moving from end to b2681e4
b2681e4 [email protected]{31 minutes ago}: rebase finished: returning to refs/heads/end
b2681e4 [email protected]{31 minutes ago}: rebase: small fixes to irrelevant files
6f80728 [email protected]{31 minutes ago}: rebase: live feedback tests
56b5212 [email protected]{31 minutes ago}: rebase: poke build bot
10bc997 [email protected]{33 minutes ago}: checkout: moving from end to 10bc997faa7d5cad52c5b3f1dc25816c13220187^0
422f15a [email protected]{25 hours ago}: rebase finished: returning to refs/heads/end
422f15a [email protected]{25 hours ago}: rebase: small fixes to irrelevant files
79d7596 [email protected]{25 hours ago}: pull --rebase: live feedback tests
52072ec [email protected]{25 hours ago}: pull --rebase: poke build bot
62c8870 [email protected]{25 hours ago}: checkout: moving from end to 62c887017d969d98ec5874698c82f94523fe5ac6^0
ca2f134 [email protected]{25 hours ago}: rebase finished: returning to refs/heads/end
ca2f134 [email protected]{25 hours ago}: rebase: small fixes to irrelevant files
8bce052 [email protected]{25 hours ago}: rebase: FeedbackViewController tests
d581615 [email protected]{25 hours ago}: rebase: live feedback tests
c9adb82 [email protected]{25 hours ago}: rebase: poke build bot
e556052 [email protected]{26 hours ago}: checkout: moving from end to e556052f0db5c674e4145e56001df08cb809f936^0
399758d [email protected]{26 hours ago}: rebase finished: returning to refs/heads/end
399758d [email protected]{26 hours ago}: rebase: small fixes to irrelevant files
3f6385d [email protected]{26 hours ago}: rebase: FeedbackViewController tests
ba01791 [email protected]{26 hours ago}: rebase: live feedback tests
e9159db [email protected]{26 hours ago}: rebase: poke build bot
問題補充:
我特別好奇這些行:
422f15a [email protected]{25 hours ago}: rebase finished: returning to refs/heads/end
422f15a [email protected]{25 hours ago}: rebase: small fixes to irrelevant files
79d7596 [email protected]{25 hours ago}: pull --rebase: live feedback tests
52072ec [email protected]{25 hours ago}: pull --rebase: poke build bot
我是如何設法pull --rebase
和rebase
在同一線?通常,當我做了pull --rebase
,它更新所有四個這些一次,如:
18cb678 [email protected]{2 days ago}: rebase finished: returning to refs/heads/end
18cb678 [email protected]{2 days ago}: pull --rebase: small fixes to irrelevant files
744ce78 [email protected]{2 days ago}: pull --rebase: FBFeedbackViewController tests
7fd9af4 [email protected]{2 days ago}: pull --rebase: live feedback tests
1b7aa06 [email protected]{2 days ago}: pull --rebase: update feedback when MQTT message is received
SOLUTION:
通過使用git reflog branch-name
而非git reflog
,我可以看到整個底墊中的一個條目操作,所以我可以回到我的項目中的那個狀態。
的git reflog branch-name --date=relative
輸出看起來是這樣的:
b2681e4 [email protected]{71 minutes ago}: rebase finished: refs/heads/end onto 10bc997faa7d5cad52c5b3f1dc25816c13220187
422f15a [email protected]{26 hours ago}: rebase finished: refs/heads/end onto 62c887017d969d98ec5874698c82f94523fe5ac6
ca2f134 [email protected]{26 hours ago}: rebase finished: refs/heads/end onto e556052f0db5c674e4145e56001df08cb809f936
399758d [email protected]{26 hours ago}: rebase finished: refs/heads/end onto 9276926e7fe7417db622e42da44e54eac4db1f85
a8ca29d [email protected]{2 days ago}: rebase -i (finish): refs/heads/end onto bfe8d25
18cb678 [email protected]{2 days ago}: rebase finished: refs/heads/end onto 967a525790be38e06b42ff314f47821ec867403f
21c2da4 [email protected]{2 days ago}: rebase finished: refs/heads/end onto f94d81aa5c3ecf6445db06692dee4f6c40d96c0b
謝謝。這回答我是如何失去承諾的。我問的第二個問題是,「我怎樣才能找到第三個最古老的提交?」一分鐘後,我會檢查一下它可能被搗毀的提交。然後我可以分裂它。 – 2013-03-13 17:25:13
@RosePerrone:使用分支的reflog,而不是'HEAD'。整個rebase操作只有1個條目。這樣你可以退出rebase並重新開始。一個簡單的'git reset --hard @ {1}'應該這樣做(因爲'@ {1}'會隱式地使用當前分支而不是'HEAD')。 – 2013-03-13 17:26:24
謝謝!爲什麼'git reflog'對當前分支和'HEAD'的行爲不同? 'man git-reflog'沒有提到它。在我想重置的提交之後,在所有堆棧提交中保存工作的最佳方式是什麼? – 2013-03-13 17:38:23