So I\'m working in a branch, make some changes, and run git merge master. I get a merge conflict on one of the files I modified (which I know how to deal with),
The reason this happened is because you most likely did the opposite of what you were intending to do.
Let's suppose your working branch is called topic-branch.
Instead of doing:
$ git merge master
you could have done:
$ git checkout master
$ git merge topic-branch
In English, instead of merging the master branch into topic-branch you could have merged topic-branch into master.
To understand why this achieves the desired result we can examine the statement made in a previous answer:
When you attempt a merge, all files that can be automatically merged (e.g. where you don't have any changes in your local branch but which have been modified on the source branch), are automatically merged and staged.
The problem you are having is simply merge trying to do its job. The files aren't changed in your topic branch, but they are on the branch you are merging into it. If you look at this in the opposite direction of merging the topic-branch into master the problem goes away because it only considers the files you've modified.
Conceptually, here is what merge is doing (more here):
Let the current head be called current, and the head to be merged called merge.
- Identify the common ancestor of current and merge. Call it ancestor-commit.
- Deal with the easy cases. If the ancestor-commit equals merge, then do nothing. If ancestor-commit equals current, then do a fast forward merge.
- Otherwise, determine the changes between the ancestor-commit and merge.
- Attempt to merge those changes into the files in current.
- If there were no conflicts, create a new commit, with two parents, current and merge. Set current (and HEAD) to point to this new commit, and update the working files for the project accordingly.
- If there was a conflict, insert appropriate conflict markers and inform the user. No commit is created.