git pull
fetches the latest changes and then merges them into your branch. Like any merge, there can be a conflict. You have to resolve the conflict.
You start with a repository like this, with some commits on top of the last commit you pulled. Git remembers the last position they saw master on the remote called origin with a remote tracking branch called origin/master
.
A - B [origin/master]
\
C - D [master]
git pull
goes in two steps. First it updates origin/master
with the latest commits.
A - B - E - F [origin/master]
\
C - D [master]
Then it does a merge.
A - B - E - F [origin/master]
\ \
C - D - M [master]
If there are conflicts, you have to resolve them. This is the same as finishing up a normal commit. Git has tried its best to produce a merge commit, but it needs you to make some decisions it cannot. Edit the files to fix the conflicts, use git add
to stage the changes, and once you've got it all fixed up, git commit
.
See "Basic Merge Conflicts" in Pro Git for how to handle that.