我在一个分支上有四个线性提交,我使用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 HEAD@{21 seconds ago}: rebase -i (finish): returning to refs/heads/end
b2681e4 HEAD@{24 seconds ago}: checkout: moving from end to b2681e4
b2681e4 HEAD@{31 minutes ago}: rebase finished: returning to refs/heads/end
b2681e4 HEAD@{31 minutes ago}: rebase: small fixes to irrelevant files
6f80728 HEAD@{31 minutes ago}: rebase: live feedback tests
56b5212 HEAD@{31 minutes ago}: rebase: poke build bot
10bc997 HEAD@{33 minutes ago}: checkout: moving from end to 10bc997faa7d5cad52c5b3f1dc25816c13220187^0
422f15a HEAD@{25 hours ago}: rebase finished: returning to refs/heads/end
422f15a HEAD@{25 hours ago}: rebase: small fixes to irrelevant files
79d7596 HEAD@{25 hours ago}: pull --rebase: live feedback tests
52072ec HEAD@{25 hours ago}: pull --rebase: poke build bot
62c8870 HEAD@{25 hours ago}: checkout: moving from end to 62c887017d969d98ec5874698c82f94523fe5ac6^0
ca2f134 HEAD@{25 hours ago}: rebase finished: returning to refs/heads/end
ca2f134 HEAD@{25 hours ago}: rebase: small fixes to irrelevant files
8bce052 HEAD@{25 hours ago}: rebase: FeedbackViewController tests
d581615 HEAD@{25 hours ago}: rebase: live feedback tests
c9adb82 HEAD@{25 hours ago}: rebase: poke build bot
e556052 HEAD@{26 hours ago}: checkout: moving from end to e556052f0db5c674e4145e56001df08cb809f936^0
399758d HEAD@{26 hours ago}: rebase finished: returning to refs/heads/end
399758d HEAD@{26 hours ago}: rebase: small fixes to irrelevant files
3f6385d HEAD@{26 hours ago}: rebase: FeedbackViewController tests
ba01791 HEAD@{26 hours ago}: rebase: live feedback tests
e9159db HEAD@{26 hours ago}: rebase: poke build bot
附加问题:
我对这些行特别好奇:
422f15a HEAD@{25 hours ago}: rebase finished: returning to refs/heads/end
422f15a HEAD@{25 hours ago}: rebase: small fixes to irrelevant files
79d7596 HEAD@{25 hours ago}: pull --rebase: live feedback tests
52072ec HEAD@{25 hours ago}: pull --rebase: poke build bot
我是如何做到pull --rebase
和rebase
在同一条线上的?通常,当我执行 a 时pull --rebase
,它会同时更新所有四个,如下所示:
18cb678 HEAD@{2 days ago}: rebase finished: returning to refs/heads/end
18cb678 HEAD@{2 days ago}: pull --rebase: small fixes to irrelevant files
744ce78 HEAD@{2 days ago}: pull --rebase: FBFeedbackViewController tests
7fd9af4 HEAD@{2 days ago}: pull --rebase: live feedback tests
1b7aa06 HEAD@{2 days ago}: pull --rebase: update feedback when MQTT message is received
解决方案:
通过使用git reflog branch-name
而不是git reflog
,我可以看到整个变基操作的一个条目,因此我可以在我的项目中回到那个状态。
的输出git reflog branch-name --date=relative
如下所示:
b2681e4 end@{71 minutes ago}: rebase finished: refs/heads/end onto 10bc997faa7d5cad52c5b3f1dc25816c13220187
422f15a end@{26 hours ago}: rebase finished: refs/heads/end onto 62c887017d969d98ec5874698c82f94523fe5ac6
ca2f134 end@{26 hours ago}: rebase finished: refs/heads/end onto e556052f0db5c674e4145e56001df08cb809f936
399758d end@{26 hours ago}: rebase finished: refs/heads/end onto 9276926e7fe7417db622e42da44e54eac4db1f85
a8ca29d end@{2 days ago}: rebase -i (finish): refs/heads/end onto bfe8d25
18cb678 end@{2 days ago}: rebase finished: refs/heads/end onto 967a525790be38e06b42ff314f47821ec867403f
21c2da4 end@{2 days ago}: rebase finished: refs/heads/end onto f94d81aa5c3ecf6445db06692dee4f6c40d96c0b