git - how to abandon changes and get back in sync with master

try to do a commit, and get a message like:

Your branch is ahead of 'origin/master' by 1 commit.


error: Pulling is not possible because you have unmerged files.

to abandon your changes and get back in sync do:

$ git reset --hard origin/master
$ git status
>   On branch master
>   Your branch is up-to-date with 'origin/master'.
>   nothing to commit, working tree clean
$ git pull
>   Already up-to-date.
$ git rev-parse origin/master
>   c9be33d5d611fe6ffdd4aca7f5beec8a8a0bdd6e
$ git rev-parse master
>   c9be33d5d611fe6ffdd4aca7f5beec8a8a0bdd6e

the last four commands are shown just to demonstrate how to verify that the two repositories are indeed back in sync.

also note: the remote and local repo’s have the default names of origin/master and master respectively.