Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git pull asks me to write merge message

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?

like image 992
Pratik Avatar asked Dec 30 '15 09:12

Pratik


People also ask

Why does git pull require merge?

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 commit ted locally to the branch you're trying to pull, and now you need to merge the remote changes with your local ones.

How do I stop git from merging messages?

press "esc" (escape) write ":wq" (write & quit)

Do we need to merge after pull?

In a pull request, you propose that changes you've made on a head branch should be merged into a base branch. By default, any pull request can be merged at any time, unless the head branch is in conflict with the base branch.

Why does git pull create a commit?

Simple answer: git pull is, essentially, a combination of git fetch and then a git merge . As any merge, if Git finds out fast-forwarding is not possible, a traditional merge is necessary (one more commit with two parents), therefore this process asks for a commit message.


1 Answers

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

like image 80
Madara's Ghost Avatar answered Sep 28 '22 12:09

Madara's Ghost