Remove a git commit which has not been pushed

前端 未结 11 727
抹茶落季
抹茶落季 2020-12-04 04:34

I did a git commit but I have not pushed it to the repository yet. So when I do git status, I get \'# Your branch is ahead of \'master\' by 1 commi

11条回答
  •  庸人自扰
    2020-12-04 04:47

    I have experienced the same situation I did the below as this much easier. By passing commit-Id you can reach to the particular commit you want to go:

    git reset --hard {commit-id}
    

    As you want to remove your last commit so you need to pass the commit-Id where you need to move your pointer:

    git reset --hard db0c078d5286b837532ff5e276dcf91885df2296
    

提交回复
热议问题