Well, as usually with git, that behaviour depends on a couple of things, in this case you are seeing that message because you got some conflicts between your colleague code and yours and it tries to make a merge commit, instead of doing a fast-forward merge.
Lets clear up the previous phrase, and for that we must start from the beginning:
When you are pulling, what you really are doing are two operations in one:
- get the remote data to your local machine (
git fetch
)
- "join" the data you just retrieved to your local branch (
git merge origin/master
)
To "join" the code you have two possible operations: merge or rebase
When doing a merge, git creates a new special commit. It contains two parents, one for your last local commit and another for the last code of the merged branch. That's why you see a bifurcation in the history line when you create a merge, if you use a GUI client or git log --graph
No matter how special it is, it is still a commit, and this it requires a message for it. This is the case you are describing.
However there is another operation you can do to bring the remote data to your local machine: rebase. In that case you'll get the remote data, and then your local commits (the ones that are not yet in the remote location) will be applied in the same order on top of the last commit your fetched. In that case you are not really creating a merge commit, so no message is needed, because the history will be kept linear.
Well, here's the trick: git pull can actually do a rebase if the operation can be completed without any conflict. That's called a fast-forward pull.
You can configure git to use whatever default you want (rebase or merge) or supply the parameters when doing the merge:
git pull --ff
, pulls the data and tries to rebase. This operation will abort if there are conflicts
git pull --no-ff
always create a merge, even if there are no conflicts
Here's an SO answer on how to configure git to use fast-forward by default
But take into consideration that even if you have ff by default, the pull operation will fallback to a normal merge if there are conflicts. If you want to force the pull to make a rebase you'll need to do
git pull --rebase
But note that doing this won't make the conflicts disappear, you'll need to fix them anyway ;)