How to revert initial git commit?

前端 未结 9 590
死守一世寂寞
死守一世寂寞 2020-11-30 16:14

I commit to a git repository for the first time; I then regret the commit and want to revert it. I try

# git reset --hard HEAD~1

I get thi

9条回答
  •  借酒劲吻你
    2020-11-30 16:51

    You just need to delete the branch you are on. You can't use git branch -D as this has a safety check against doing this. You can use update-ref to do this.

    git update-ref -d HEAD
    

    Do not use rm -rf .git or anything like this as this will completely wipe your entire repository including all other branches as well as the branch that you are trying to reset.

提交回复
热议问题