如何恢复/取消 git reset --soft HEAD~20

问题描述 投票:0回答:1

我想压缩一些提交,然后我遵循了这个问题。所以我就这么做了:

git reset --soft HEAD~20
git commit
git push -f

我不知道为什么,但现在我的分支充满了以前没有的合并。我想恢复

git reset --soft HEAD~20
命令。怎么办?

更新

重置前我做了:

git reset < commit hash
:移动到 HEAD~20 > 然后
git push
我得到:

error: failed to push some refs to 'https://[email protected]/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 revert git-reset
1个回答
2
投票

运行:

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

© www.soinside.com 2019 - 2024. All rights reserved.