besson3c
besson3c

Reputation: 148

Git pull is always invoking merge

For some reason, whenever I git pull to update my codebase, instead of it invoking the usual sort of pull from origin/master to master I'm prompted to specify commit history with all of the usual merge details pre-filled. It is doing this for absolutely every update, no matter how mundane, and of course I'm not making any changes to this local codebase that require any merging.

Any idea what might be causing this?

Upvotes: 2

Views: 541

Answers (2)

John Szakmeister
John Szakmeister

Reputation: 47032

git pull will create a merge commit if your local master branch contains a commit not present on the remote, and then prompt you to edit the message. If your local master was a direct descendent (contained no commits that were not already on the remote), then git pull would simply fast-forward the branch and not ask for a message. Of course, this may depend on your setting of merge.ff as well (check the git-config man page for details). If merge.ff is set to false, then all merges will create a merge commit and prompt you for a message.

Given your situation, I would check to see if merge.ff is set to false. You can check it with:

git config --get merge.ff

If it comes back empty or true, then it is set to true. If you like this setting, but would like to enable fast-forward merges in this repository, you can do that with:

git config --local merge.ff true

For me, I've not enjoyed the merging behavior of git pull in general, so I've chosen to do this instead:

git fetch --all
git merge --ff --ff-only @{u}

Which will always attempt to fast-forward update my local branch unless I have changes. When I do, it complains, and then I choose which path I want to take to resolution (which is often rebase, but not always).

Some history behind editing merge messages

Back in 1.7.10 git started bringing up the log message for merge commits in an editor, instead of blindly keeping the templated message. The reason for this came from Linus and the Linux Kernel tree, where far too many people were keeping the default merge message and not supplying something more substantial.

Upvotes: 2

Gaurav Aradhye
Gaurav Aradhye

Reputation: 344

If you want to work on a clean branch (not on a branch which already has your commits), then you have the option to replicate the remote branch multiple times with different names.

E.g. If you want to work on master branch, but facing problems with local "master" branch, then create a new branch to track master branch using

git branch --track localBranchName origin/master git checkout localBranchName

Now you have your local branch "localBranchName" to track remote master branch. Work on this branch!

Hopefully you won't face any problems on this new branch.

Upvotes: 0

Related Questions