How can I find the location of origin/master in git, and how do I change it?

前端 未结 13 529
悲哀的现实
悲哀的现实 2020-12-02 03:33

I\'m a Git newbie. I recently moved a Rails project from Subversion to Git. I followed the tutorial here: http://www.simplisticcomplexity.com/2008/03/05/cleanly-migrate-yo

13条回答
  •  天命终不由人
    2020-12-02 04:01

    It is possible to reset to a specific commit before your own commits take place.

    $ git status
    # On branch master
    # Your branch is ahead of 'origin/master' by 2 commits.
    #
    nothing to commit (working directory clean)
    

    Use git log to find what commit was the commit you had before the local changes took place.

    $ git log
    commit 3368e1c5b8a47135a34169c885e8dd5ba01af5bb
    ...
    commit baf8d5e7da9e41fcd37d63ae9483ee0b10bfac8e
    ...
    

    Take note of the local commits and reset directly to the previous commit:

    git reset --hard baf8d5e7da9e41fcd37d63ae9483ee0b10bfac8e
    

提交回复
热议问题