[英]Undo a git squash rebase
I messed up squashing my commits into one commit.我搞砸了将我的提交压缩成一个提交。
If the commits went如果提交去了
NOTMINE -> MINE1 -> MINE2 -> MINE3 -> MINE4 -> MINE5
NOTMINE -> MINE1 -> MINE2 -> MINE3 -> MINE4 -> MINE5
I tried to squash MINE1-4 into MINE5, but ended up squashing them into NOTMINE.我试图将 MINE1-4 压缩为 MINE5,但最终将它们压缩为 NOTMINE。
I ran git rebase -i HEAD~5
and set it to pick MINE5 and squash MINE1-4.我运行了
git rebase -i HEAD~5
并将其设置为选择 MINE5 并压缩 MINE1-4。
In order to fix this I tried git reflog
and based on that I ran git reset --hard HEAD@{1}
, which looked like the moment before the squash, but that had no effect.为了解决这个问题,我尝试
git reflog
并在此基础上运行git reset --hard HEAD@{1}
,这看起来像是壁球之前的那一刻,但这没有效果。
Any ideas?有任何想法吗?
Check your reflog.检查你的 reflog。
One line should indicate the beginning of your rebase:一行应该表明你的变基的开始:
<sha> HEAD@{xx} rebase (start): checkout <something>
(since you asked for git rebase -i HEAD~5
, <something>
will probably be an explicit sha1; (因为您要求
git rebase -i HEAD~5
, <something>
可能是一个明确的 sha1;
when you ask for a named ref as in git rebase -i origin/master
, the log mentions that name)当您在
git rebase -i origin/master
中要求命名参考时,日志会提到该名称)
The line below that one ( <sha> HEAD@{xx+1}
) is the commit you are looking for.该行(
<sha> HEAD@{xx+1}
)下方的行是您要查找的提交。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.