问题描述
我想将我的最后2个提交压缩成一个,所以做了一个 git rebase
,如下所示:
git rebase -i HEAD〜2
但由于一个错字,实际上最终导致原来的错误是:
git rebase -i HEAD- 3
现在,在它显示了一些其他无关提交的提交。所以基本上,我想删除不属于我的提交 06674f0
,同时在此PR中保留 fcea5e0
p>
如何解决由简单错字造成的混乱?
检查您的reflog
git reflog
选择第一个rebase之前的提交,并用下面的适当数字替换x:
只需撤消上一次rebase并重做即可:
git reset --hard HEAD @ {x}
git rebase -i HEAD〜2
。 。
git push -f origin master
移除您的拉取请求并发出新请求。
I wanted to squash my last 2 commits into one, so did a git rebase
, in following way:
git rebase -i HEAD~2
but due to a typo, what I actually ended up pushing into origin was:
git rebase -i HEAD-3
Now, in the Github Pull Request it shows commit of some other unrelated commit. so basically, I want to remove commit 06674f0
which isn't mine, while keeping fcea5e0
in this PR.
how to fix the mess caused by simple typo?
Edit: Check your reflog with
git reflog
Pick the commit previous to your first rebase and replace the x with appropriate number below:
Just undo your last rebase and redo it:
git reset --hard HEAD@{x}
git rebase -i HEAD~2
..
git push -f origin master
Remove your pull request and issue a new one.
这篇关于撤销在GIT中压缩提交时犯的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!