How to revert last commit and remove it from history?

后端 未结 5 763
花落未央
花落未央 2020-12-12 19:08

I did a commit and reverted with

git revert HEAD^

just git log

➜  git:(master) git log
commit 45a0b1371e4705c4f875141232d7         


        
5条回答
  •  囚心锁ツ
    2020-12-12 19:46

    There is a nice solution here. To delete the last (top) commit you can do

    git push [remote] +[bad_commit]^:[branch]
    

    where [bad_commit] is the commit that [branch] currently points to, or if the [branch] is checked out locally, you can also do

    git reset HEAD^ --hard
    git push [remote] -f
    

提交回复
热议问题