cmac
cmac

Reputation: 916

git local branch and origin/master still diverged after git reset --hard

After doing

git reset --hard

I expected to see 'HEAD is now at hexNumber' and then 'on branch master....nothing to commit. Instead I see

    wb316-mac03:MoodTrack student$ git reset --hard
    HEAD is now at ec11193 preparation for merge
    wb316-mac03:MoodTrack student$ 
    wb316-mac03:MoodTrack student$ git status
    # On branch master
    # Your branch and 'origin/master' have diverged,
    # and have 2 and 9 different commits each, respectively.
    #
    nothing to commit (working directory clean)

I want to be completely overwritten by what's in the remote master (without recloning). Did I do something wrong?

Upvotes: 3

Views: 1474

Answers (2)

mipadi
mipadi

Reputation: 410562

You should add the commit that you want to reset to:

$ git reset --hard origin/master

git reset --hard will just reset to HEAD (which was probably master in your case).

Upvotes: 5

ferrants
ferrants

Reputation: 631

If you want what is in the remote master and do not care what is two ahead on your branch, check out another branch, delete the master and then pull down the remote.

git checkout -b master_tmp
git branch -D master
git checkout -t origin/master
git branch -D master_tmp

Best of luck.

Upvotes: 0

Related Questions