How to revert initial git commit?

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

    I will throw in what worked for me in the end. I needed to remove the initial commit on a repository as quarantined data had been misplaced, the commit had already been pushed.

    Make sure you are are currently on the right branch.

    git checkout master

    git update-ref -d HEAD

    git commit -m "Initial commit

    git push -u origin master

    This was able to resolve the problem.

    Important

    This was on an internal repository which was not publicly accessible, if your repository was publicly accessible please assume anything you need to revert has already been pulled down by someone else.

提交回复
热议问题