Undo a Mistake made while squashing the commits in GIT

前端 未结 2 1012
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-04 04:16

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, wha

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-04 04:21

    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.

提交回复
热议问题