在过去的一周里,我已经挑选了70多个具有命令的分支从我的主分支提交到另一个分支:
git cherry-pick -x -n <commit-id>
(made some modifications and then)
git commit状态显示,您的分支在76次提交中领先于“原产地/另一个分支”。
就在刚才,我想我可以继续我的任务,并挑选一些承诺。今天的第一次提交是错误的,想要取消这种挑选,并使用了以下命令:
git cherry-pick --abort而繁荣,所有的70+承诺似乎都消失了。状态说明您的分支比“原产地/另一个分支”领先2次提交。
Reflog显示了最后两行:
c398477f HEAD@{0}: reset: moving to c398477fa2b2e0e78cb628c75df81b2c1ec411cd
8369312d HEAD@{1}: checkout: moving from master to another-branch请说有可能以某种方式恢复?--这些提交仅在我的本地分支中。而且,,它到底是如何擦去所有的樱桃-选择的提交,即使在我明确地把它们每一个都背出来之后?
就在一周前我开始采樱桃的时候,这就是我的翻版:
d8a71aca HEAD@{52}: checkout: moving from another-branch to dev
8369312d HEAD@{53}: commit: xxx
...
3bb1ff07 HEAD@{127}: commit: xxx
2b9b6542 HEAD@{128}: commit: xxx
c398477f HEAD@{129}: reset: moving to HEAD^
b373db60 HEAD@{130}: commit: xxx
c398477f HEAD@{131}: commit: xxx
8fb419aa HEAD@{132}: commit: xxx
844cbe24 HEAD@{133}: reset: moving to 844cbe2499aadcd0d014999ddb6f847c1d940440
844cbe24 HEAD@{134}: reset: moving to 844cbe24
41e7dbed HEAD@{135}: checkout: moving from 844cbe2499aadcd0d014999ddb6f847c1d940440 to aller-dev
844cbe24 HEAD@{136}: checkout: moving from another-branch to 844cbe24
41e7dbed HEAD@{137}: reset: moving to HEAD^
844cbe24 HEAD@{138}: reset: moving to HEAD^
81bf86ac HEAD@{139}: cherry-pick: xxx
844cbe24 HEAD@{140}: checkout: moving from dev to another-branchreflog --all也是如此
c398477f refs/heads/another-branch@{0}: reset: moving to c398477fa2b2e0e78cb628c75df81b2c1ec411cd
8369312d refs/heads/another-branch@{1}: commit: xxx
6a4da110 refs/heads/another-branch@{2}: commit: xxx
...
2b9b6542 refs/heads/another-branch@{75}: commit: xxx
c398477f refs/heads/another-branch@{76}: reset: moving to HEAD^
b373db60 refs/heads/another-branch@{77}: commit: xxx
c398477f refs/heads/another-branch@{78}: commit: xxx
8fb419aa refs/heads/another-branch@{79}: commit: xxx,我可以退房到 8369312d ,这是在 reset: moving to c398477fa2b2e0e78cb628c75df81b2c1ec411cd之前的
发布于 2017-11-10 01:12:53
我认为(但不能用上面的文本来证明),您必须使用多个提交开始最初的摘樱桃操作,例如,使用以下内容:
git cherry-pick -x 1234567..fedcba9 # possibly with -n too这会触发Git的“测序器”。如果某个单独的pick操作失败,那么剩下的选中操作将留待执行,然后完全退出命令。这将导致后来的git cherry-pick --abort将事情放回保存的ORIG_HEAD,使您之间所做的70多次提交似乎消失了。
我可以直接退房到
8369312d,这是在reset: moving to c398477fa2b2e0e78cb628c75df81b2c1ec411cd之前的吗?
我相信是这样的。请注意,这将给您一个“独立的头”,这是好的。如果git log随后显示了您想要的内容,那么后续的git checkout -b <newbranch>将创建一个新的分支名称,您可以使用它来处理提交。
https://stackoverflow.com/questions/47213772
复制相似问题