How to revert initial git commit?

前端 未结 9 614
死守一世寂寞
死守一世寂寞 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:46

    I wonder why "amend" is not suggest and have been crossed out by @damkrat, as amend appears to me as just the right way to resolve the most efficiently the underlying problem of fixing the wrong commit since there is no purpose of having no initial commit. As some stressed out you should only modify "public" branch like master if no one has clone your repo...

    git add 
    git commit --amend --author="author name "-m "new message"
    

提交回复
热议问题