Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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)

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

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
share|improve this answer
    
Thanks. That did it. Is there a create branch command that I can use that does this automatically? –  Andrew Arnott Sep 1 '09 at 1:39
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.