我想压缩一些提交,然后我关注了 this 所以我这么做了:
git reset --soft HEAD~20
git commit
git push -f
我不知道为什么,但现在我的分支充满了以前没有的 merge 我想恢复 git reset --soft HEAD~20 命令 如何做呢? 谢谢!!
更新
我做了:
git reset < 重置前提交哈希:移动到 HEAD~20 >
那么
git 推送
我得到:
error: failed to push some refs to 'https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1169696969517378657364727a74653f7e6376" rel="noreferrer noopener nofollow">[email protected]</a>/xxxx/xxxx.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
最佳答案
运行:
git reflog
它会向您显示如下内容:
0475497 (HEAD -> master) HEAD@{0}: reset: moving to HEAD~20
ab155bc HEAD@{1}: commit: commit before reset
5da1f69 HEAD@{2}: commit: commit message
c2d9604 HEAD@{3}: commit: commit message
.
.
.
然后,您可以使用其提交哈希(在上面的示例中为 ab155bc
)来 checkout 或重置到重置之前的提交
关于git - 如何恢复/取消 git reset --soft HEAD~20,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66137796/