threads / discuss / 26778

Question about "branch.<name>.merge"

Subject: Question about "branch.<name>.merge"

## tl;dr

2 messages between Mar 18, 2011 and Mar 18, 2011.

replies: 1people: 2as markdown or json

Josh Ralburton· Mar 18, 2011, 19:35 UTC · lore
This is a typical section from a .git config file:
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git://git.kernel.org/pub/scm/git/git.git
[branch "master"]
    remote = origin
    merge = refs/heads/master

I am curious why "branch.master.merge=refs/heads/master" was implemented to refer to the remote branch (refs/heads/master) rather than the local branch (refs/remotes/origin/master).

Thanks.
Josh
Junio C Hamano· Mar 18, 2011, 21:13 UTC · re: Josh Ralburton · lore

Re: Question about "branch.<name>.merge"

Josh Ralburton <josh.ralburton@gmail.com> writes:
Show 12 quoted lines
> This is a typical section from a .git config file:
>
> [remote "origin"]
>     fetch = +refs/heads/*:refs/remotes/origin/*
>     url = git://git.kernel.org/pub/scm/git/git.git
> [branch "master"]
>     remote = origin
>     merge = refs/heads/master
>
> I am curious why "branch.master.merge=refs/heads/master"  was
> implemented to refer to the remote branch (refs/heads/master) rather
> than the local branch (refs/remotes/origin/master).

Because conceptually you are merging with the refs/heads/master branch that exists at the "origin" repository, not merging with a remote tracking branch that the "origin" repository may have to track its upstream.

It is immaterial that you happen to have a copy of it at your own remote tracking branch (i.e. refs/remotes/origin/master). If you don't need tracking branches, you can even do something like this:

	[remote "origin"]
                url = git://...there
        [branch "master"]
		remote = origin
                merge = refs/heads/master

Notice that you are telling git not to create any remote tracking branches with this configuration.

← back to recent threads