I'm using msysgit (Git for Windows). It used to be that running "git pull" would automatically "git fetch", and then rebase my changes on every branch with the new HEAD from upstream. Now it seems "git pull" usually just gives me errors about how I have no "branch.*.merge" set in my configuration file. When this worked before, I hadn't done anything special in my config file. Is it how I create my local branches? I usually do this:

git checkout -b localbranch origin/remotebranch

Is that the best way to create branches such that "git pull" will merge them automatically? (because it doesn't seem to be working for me)

2 Answers 2


You need something similar to the following in your config file:

[branch "master"]
    remote = origin
    merge = refs/heads/master

If you need to add this information for an existing branch, you can use the command:

git branch --set-upstream mybranch origin/remotebranch

If you're creating a new branch, you can ensure the branch is a remote tracking branch by using one of the commands:

git branch --track mybranch origin/remotebranch
git checkout --track -b mybranch origin/remotebranch

However, --track should be the default. If it isn't, then the setting branch.autosetupmerge might be set to false. To reset it, you can set it to true or unset it:

git config --global branch.autosetupmerge true
git config --global --unset branch.autosetupmerge
  • Thanks. That did it. Is there a create branch command that I can use that does this automatically? Sep 1, 2009 at 1:39

Be careful with the above. I'm only familiar with git on Linux, so details might vary.

"git fetch" gets the changes, does nothing else "git pull" does a "git fetch" and then a "git merge" (i.e., it merges the remote changes into the current stuff) "git pull -r" does a "git fetch" and then a "git rebase" (i.e., updates the tip of the branch where you are to the remote one and then rebases your changes on top)

My help for "git pull" (version 1.8.1-290) directs me to look at branch.<name>.rebase and branch.autosetuprebase in "git config" to set this up automatically.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .