Undo a Mistake made while squashing the commits in GIT

前端 未结 2 1024
爱一瞬间的悲伤
爱一瞬间的悲伤 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:27

    Both git reset --hard HEAD{x} and git reset --hard HEAD@{x} didn't work for me.

    I wanted a script to do this anyways, so I did the following.

    BACK_2_SHA=`git reflog show --pretty=format:'%H' -n x | tail -n 1`
    git reset --hard $BACK_2_SHA
    

提交回复
热议问题