I ran into a merge conflict. How do I abort the merge?

Question

I used git pull and had a merge conflict:

unmerged:   some_file.txt

You are in the middle of a conflicted merge.

How do I abandon my changes to the file and keep only the pulled changes?

Answer

Since your pull was unsuccessful then HEAD (not HEAD^) is the last "valid" commit on your branch:

git reset --hard HEAD

The other piece you want is to let their changes over-ride your changes.

Older versions of git allowed you to use the "theirs" merge strategy:

git pull --strategy=theirs remote_branch

But this has since been removed, as explained in this message by Junio Hamano (the Git maintainer). As noted in the link, instead you would do this:

git fetch origin
git reset --hard origin

How to fully delete a git repository created with init?

How do I programmatically determine if there are uncommitted changes?