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?
If your git version is >= 1.6.1, you can use
git reset --merge.
Also, as @Michael Johnson mentions, if your git version is >= 1.7.4, you can also use
git merge --abort.
As always, make sure you have no uncommitted changes before you start a merge.
From the git merge man page
git merge --abort is equivalent to
git reset --merge when
MERGE_HEAD is present.
MERGE_HEAD is present when a merge is in progress.
Also, regarding uncommitted changes when starting a merge:
If you have changes you don’t want to commit before starting a merge, just
git stash them before the merge and
git stash pop after finishing the merge or aborting it.
git merge --abort
Abort the current conflict resolution process, and try to reconstruct
the pre-merge state.
If there were uncommitted worktree changes present when the merge
git merge --abortwill in some cases be unable to
reconstruct these changes. It is therefore recommended to always
commit or stash your changes before running git merge.
git merge --abortis equivalent to
git reset --mergewhen