Repository navigation
branch: let inherit track a remote-tracking start point - #2450
Open
HaraldNordgren wants to merge 1 commit into
Open
HaraldNordgren wants to merge 1 commit into
HaraldNordgren wants to merge 1 commit into
Conversation
HaraldNordgren
force-pushed
the
hn/branch-inherit-remote-tracking
branch
from
October 15, 2026 22:28
e5ef88c to
32969fc
Compare
HaraldNordgren
marked this pull request as ready for review
October 16, 2026 07:01
Contributor
Author
|
/submit |
|
Submitted as pull.2450.git.git.1792134165785.gitgitgadget@gmail.com To fetch this version into To fetch this version to local tag |
|
Junio C Hamano wrote on the Git mailing list (how to reply to this email): "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> `inherit`;; if the starting point has a tracking configuration, it is copied to the new
> - branch
> + branch. A remote-tracking starting point is tracked directly, as with `true`.
That is "A remote-tracking branch given as a starting point", not "A
remote-tracking starting point". Don't abbreviate and drop "branch".
If a starting point is not a remote-tracking branch, shouldn't the
same thing happen, by the way? IOW, shouldn't the updated text and
behaviour be more like
`inherit`;; if the starting point has a tracking
configuration, it is copied to the new branch. Otherwise,
the new branch is set to track the starting point itself.
I am not sure if it is the users of `inherit` want that forking a
new branch from something that they know is *not* tracking anything
suddenly starts to track the starting point (whether it is a
remote-tracking branch or something else).
Looking at the originating commit d3115660b4 (branch: add flags and
config to inherit tracking, 2021-12-20), it only talks about what
they want to do when the starting point does track something, and
forgets to say what they want when it does not track anything (the
author CC'ed in case he retains the memory of the motivation from 5
years ago), but if you ask me _now_, not doing anything, i.e., the
behaviour the old commit happened to have implemented without
explanation does sound like the right thing to do.
What we should do if this change of behaviour turns out to be
undesirable?
Perhaps `inherit` should gain a synonym `inherit-or-ignore` for
those who prefer the current behaviour, and we want two extra
behaviours, `inherit-or-fail` that complains and dies if the
specified starting point does not have anything for the new branch
to inherit, and `inherit-or-direct` that uses the fallback
definition, or something? |
With branch.autoSetupMerge=inherit, "git switch topic" creates a local topic branch from origin/topic with no upstream, and warns that no remote is set. "git switch -c topic origin/topic" and an explicit "--track=inherit" do the same. A remote-tracking branch has no upstream of its own to copy. Make inherit use it as the upstream directly, as the default "true" does, so that inherit sets up tracking in every case the default does. Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
HaraldNordgren
force-pushed
the
hn/branch-inherit-remote-tracking
branch
from
October 17, 2026 09:51
32969fc to
c39c2f2
Compare
|
Harald Nordgren wrote on the Git mailing list (how to reply to this email): On Fri, Oct 16, 2026 at 6:55 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > `inherit`;; if the starting point has a tracking configuration, it is copied to the new
> > - branch
> > + branch. A remote-tracking starting point is tracked directly, as with `true`.
>
> That is "A remote-tracking branch given as a starting point", not "A
> remote-tracking starting point". Don't abbreviate and drop "branch".
Thanks!
> I am not sure if it is the users of `inherit` want that forking a
> new branch from something that they know is *not* tracking anything
> suddenly starts to track the starting point (whether it is a
> remote-tracking branch or something else).
For me it's simple, only tracking when the starting point is a remote branch.
> Looking at the originating commit d3115660b4 (branch: add flags and
> config to inherit tracking, 2021-12-20), it only talks about what
> they want to do when the starting point does track something, and
> forgets to say what they want when it does not track anything (the
> author CC'ed in case he retains the memory of the motivation from 5
> years ago), but if you ask me _now_, not doing anything, i.e., the
> behaviour the old commit happened to have implemented without
> explanation does sound like the right thing to do.
>
> What we should do if this change of behaviour turns out to be
> undesirable?
>
> Perhaps `inherit` should gain a synonym `inherit-or-ignore` for
> those who prefer the current behaviour, and we want two extra
> behaviours, `inherit-or-fail` that complains and dies if the
> specified starting point does not have anything for the new branch
> to inherit, and `inherit-or-direct` that uses the fallback
> definition, or something?
Seems quite overkill for the relatively small problem this is solving.
But it would be interesting to hear the original author's POV.
Harald |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
branch.autoSetupMerge=inherit, makegit switch -c new_branch upstream/masterwork without a warning, and sets the remote branchupstream/masteras the upstream.