Git pull asks me to write merge message

Pratik picture Pratik · Dec 30, 2015 · Viewed 40.3k times · Source

I pull from my branch:

git checkout mybranchSample
git fetch
git pull origin master

Then, Git gives me the following message:

Please enter a commit message to explain why this merge is necessary,
especially if it merges an updated upstream into a topic branch

enter image description here

And after entering a commit message, it merges master into my files. And even though I haven't worked on some files from master, it shows the files list in green when I type git status.

This issue is not happening with my colleagues, but me only. What can be the reason behind this?

Answer

Madara's Ghost picture Madara's Ghost · Dec 30, 2015

git pull is basically two actions at once: git fetch followed by a git merge (unless you use git pull --rebase, in which case you can guess what happens).

The reason you're seeing this is because Git can't do a fast-forward merge, like it can most of the time. The reason for that is usually because you've git committed locally to the branch you're trying to pull, and now you need to merge the remote changes with your local ones.

It's also worth noting that Git pre-populated the merge message for you, so you don't really need to type anything. Just save and exit, and the merge should be complete. (Unless, of course, there are merge conflicts).