Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
497 views
in Technique[技术] by (71.8m points)

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

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.

question from:https://stackoverflow.com/questions/65917338/git-pull-doesnt-merge-but-git-pull-origin-branch-name-does-why

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...