Skip to contentSkip to conversation

git-branch silently ignores --track on local branches

DISCUSSION Wayne Davison 3 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

I used to be able to create a branch that tracked master (or another local branch) by using "git branch --track new-branch" from that checked-out branch. However, this functionality was apparently removed and now the --track option is silently ignored for local branches. I'd love to have this functionality restored. Is there a problem with local branches being supported when explicitly requested?

..wayne..

#1 lore raw
Quoted 3 lines · Wayne Davison

... Is there
a problem with local branches being supported when explicitly requested?

Maybe this one?

commit 6f084a56fcb3543d88d252bb49c1d2bbf2bd0cf3

Author: Johannes Schindelin <[email protected]>
Date:   Tue Jul 10 18:50:44 2007 +0100

branch --track: code cleanup and saner handling of local branches

This patch cleans up some complicated code, and replaces it with a cleaner version, using code from remote.[ch], which got extended a little in the process. This also enables us to fix two cases:

The earlier "fix" to setup tracking only when the original ref started with "refs/remotes" is wrong. You are absolutely allowed to use a separate layout for your tracking branches. The correct fix, of course, is to set up tracking information only when there is a matching remote.<nick>.fetch line containing a colon.

Another corner case was not handled properly. If two remotes write to the original ref, just warn the user and do not set up tracking.

As a local branch does not have to be "fetched", the restriction on "remote.<nick>.fetch" is sort of pointless.

Also why remote.<nick>.fetch needs a colon, I begin to wonder. You can be keep fetching and merging from the same branch of the same remote without keeping a remote tracking branch for that, but the above "correct fix" forbids that.

Dscho, what were we smoking when we made this change?

#2 lore raw

Hi,

Quoted 24 lines · Junio C Hamano
Quoted 3 lines · Wayne Davison

... Is there
a problem with local branches being supported when explicitly requested?

Maybe this one?

commit 6f084a56fcb3543d88d252bb49c1d2bbf2bd0cf3

Author: Johannes Schindelin <[email protected]>
Date:   Tue Jul 10 18:50:44 2007 +0100

branch --track: code cleanup and saner handling of local branches

This patch cleans up some complicated code, and replaces it with a cleaner version, using code from remote.[ch], which got extended a little in the process. This also enables us to fix two cases:

The earlier "fix" to setup tracking only when the original ref started with "refs/remotes" is wrong. You are absolutely allowed to use a separate layout for your tracking branches. The correct fix, of course, is to set up tracking information only when there is a matching remote.<nick>.fetch line containing a colon.

Quoted 8 lines

Another corner case was not handled properly. If two remotes write to the original ref, just warn the user and do not set up tracking.

As a local branch does not have to be "fetched", the restriction on "remote.<nick>.fetch" is sort of pointless.

IIRC it was you, Junio, who complained first that the local branches have tracking set up.

Quoted 4 lines

Also why remote.<nick>.fetch needs a colon, I begin to wonder. You can be keep fetching and merging from the same branch of the same remote without keeping a remote tracking branch for that, but the above "correct fix" forbids that.

The point here was to find out what to track when we do a "git branch --track <name> <origname>". So we definitely only want to find those remotes that fetch to a certain tracking branch.

Sure, you can set up branch.<x>.merge to a branch that is not tracked. But git cannot find out which one it is in the command "branch".

Quoted 1 line

Dscho, what were we smoking when we made this change?

Dude, I, uh, I think I, uh, don't remember. Peace.

Ciao,
Dscho