`git pull` doesn't merge, but `git pull origin <branch-name>` does, why?

Viewed 118

And it's like that for all branches. Looks like git pull stopped merging my current branch with the latest remote for some reason. It must be some configuration issue? When I do git pull origin <branch-name> then everything works as expected.

Note that when I did git st I got the following:

$ git st
On branch <name>
Your branch is behind 'origin/<name>' by 139 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

So it seems the branch is tracked properly. But then git pull didn't update the branch.

2 Answers

git pull combines a git fetch and git merge.

There are three levels of configuration for default pull behavior:

  • pull.rebase which is equivalent to git pull --rebase (combine a series of commits to a new base commit):

When true (git config branch.master.rebase true) rebase branches on top of the fetched branch, instead of merging the default branch from the default

  • branch.autosetuprebase (git config --global branch.autosetuprebase always):

When a new branch is created with git branch or git checkout that tracks another branch, this variable tells Git to set up pull to rebase instead of merge When never, rebase is never automatically set to true. When local, rebase is set to true for tracked branches of other local branches. When remote, rebase is set to true for tracked branches of remote-tracking branches. When always, rebase will be set to true for all tracking branches. See "branch.autoSetupMerge" for details on how to set up a branch to track another branch. This option defaults to never.

  • branch.<branchname>.rebase:

When true, rebase the branch on top of the fetched branch, instead of merging the default branch from the default remote when "git pull" is run.

As a side git config --help is your friend.

The less verbose git pull uses the default settings.

git pull is equivalent to git fetch origin && git merge origin/<upstream>, while the verbose git pull origin master pulls changes from the remote master, and merge them to your current branch.

Related