Git, How to reset origin/master to a commit?

后端 未结 4 1936
我在风中等你
我在风中等你 2020-12-04 04:44

I reset my local master to a commit by this command:

git reset --hard e3f1e37

when I enter $ git status command, terminal says

4条回答
  •  情话喂你
    2020-12-04 05:03

    origin/xxx branches are always pointer to a remote. You cannot check them out as they're not pointer to your local repository (you only checkout the commit. That's why you won't see the name written in the command line interface branch marker, only the commit hash).

    What you need to do to update the remote is to force push your local changes to master:

    git checkout master
    git reset --hard e3f1e37
    git push --force origin master
    # Then to prove it (it won't print any diff)
    git diff master..origin/master
    

提交回复
热议问题