Git pull asks me to write merge message

If you were trying to merge master to mybranchSample branch, then this is perfectly normal.

Git merges master to mybranchSample (when you did git pull origin master from mybranchSample branch) and commits the merge changes for you (unless there is any conflict) and gives you the pre-populated message. You can just save and exit.

BUT If you were just trying to get the latest code from the remote master branch to merge with local master branch, then you should checkout out to master and then pull from master.

from you statement

it merges master files into my files. And even though I havent worked on some files from master, it shows the files list in Green when I type git status.

I think you are trying to do the second one.

so, try:

git checkout master
git pull origin master

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).


The reason this is only happening to you is not that your config is different, but that the branch you're merging in is different.

The reason for the files in the diff that you did not change is that after a merge, the new commit has to parent commits: The commit you did last and the newest commit on master. The new commit contains all changes/files. So if you diff from new to your last commit you will see all the files as changed/added that were changed/added on master while your branch was out of sync with the master branch.


Linus Torvalds explains it best:

Spreading the word about an upcoming 'git' UI change, since I'm largely to blame.

This change hopefully makes people write merge messages to explain their merges, and maybe even decide not to merge at all when it's not necessary.

I've been using that git feature for the last few weeks now, and it has resulted in my merges from submaintainers having various notes in them (well, at least if the submainter gave me any). So I'm trying to lead by example.

But if you don't like explaining your merges, this might be annoying. Of course, if you don't explain your merges, you are annoying, so it all evens out in the end. "Karmic balance", so to say.

Source: https://plus.google.com/+LinusTorvalds/posts/SrePhcj6XJe