I wanted to squash few commits and I followed this question. So I did:
git reset --soft HEAD~20
git commit
git push -f
I don't know why but now my branch full of merging which wasn't before. I want to revert the git reset --soft HEAD~20
command. How can it be done?
Update
I did: git reset < commit hash
before the reset: moving to HEAD~20 >
then git push
and I'm getting:
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 reflog
to get the sha-1 for the commit which you want your HEAD to point to . And then itsgit reset --hard <commit-hash>
to restore your branch back to that commit.--force-with-lease
whenever you can...