On 10/05/2012 12:49 am, Brad wrote:
Could 'Merge branch
master, remote-tracking branch origin' be what happens if I accidentally
typed "git merge origin master"? If I do this, what happens exactly?

Good guesswork!

One of git's merge algorithms is called an 'octopus merge', and merges more than two branches together. When you run 'git merge origin master', the fact that you named two branches (OK, 'origin' isn't a branch, but bear with me) causes the octopus merge algorithm to be invoked.

However, this algorithm is pretty old, no-one really uses it any more, and it's normally regarded as nothing more than a curiosity. Therefore it doesn't receive much love, and has some rather odd corner cases and bugs.

One such corner case is when one of the branches it's given to merge isn't a branch at all, and is instead the name of a remote. When this happens, you get the message you described, and some other stuff -- an empty merge commit I think? And I seem to recall there's another very strange oddness.

So, long story short, do not type 'git merge origin master'.
If you want an easier way to merge (with less typing) read on...

Do you know about git's branch tracking stuff? Basically, you can assign each branch an 'upstream' branch (defined in git's config). When you run 'git pull', git will merge in this upstream branch by default. ('git push' follows a different set of rules by default, although this might change. Read push.default in man git-config for now).

When a branch has an upstream configured, '@{upstream}', or '@{u}' points to that upstream branch. You can also see whether a branch has an upstream by typing 'git branch -vv' -- the upstream appears in square brackets.

So, to configure an upstream (if you don't have one set already), use 'git branch --set-upstream master origin/master', or 'git push -u origin master' if you want to push at the same time. Having done this, you can type 'git merge @{u}' (with master checked out) to merge origin/master into master.

Hope that cleared up some confusion.


You received this message because you are subscribed to the Google Groups "Git for 
human beings" group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to