git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] branch: let inherit track a remote-tracking start point

From
Harald Nordgren <haraldnordgren@gmail.com>
Date
Oct 18, 2026, 15:19 UTC
Message-ID
<CAHwyqnV=iiocV2FA32-X8LTgYwWmzQguPtkykFKM-t7B7ttNOw@mail.gmail.com>
In-Reply-To
<d2264240-1530-48a2-ac3e-ae46f855872f@gmail.com>
Show 11 quoted lines
> For me it depends on what I'm forking from. If I create a branch on my
> desktop, push it to my server and then create a local branch from that
> on my laptop, I normally want the new branch to track something like
> origin/master rather than the starting point. However, if I create a new
> branch from origin/master then I do want to track the starting point. So
> it is not clear to me that the behavior proposed here is better than the
> current behavior, but equally I don't think it is any worse. Having some
> way of saying "set up tracking when the starting point matches one of
> these patterns" might be useful, but I find the tracking options to "git
> switch -c" so confusing I normally just run "git branch
> --set-upstream-to" afterwards to set the upstream I want.

I don't actually use 'git switch -c', I just used that in the example because it's the *modern* way to do things. In reality I always run 'git checkout -b'. I agree about `set-upstream-to`, there is probably no single terminal command that I run more than

    git branch --set-upstream-to=origin

Your example got me thinking. Maybe we should go the other way? If we can inherit from the branch we are coming from, should we do that as first prio? Because of the `--set-upstream-to=origin` usage, we will likely already be tracking the right one. So

    git checkout -b first_branch
    git branch --set-upstream-to=origin/master
    git checkout -b new_branch origin/another_branch

could give us a 'new_branch' that tracks what 'first_branch' tracked, i.e. 'origin/master'. Maybe as a fallback, we could have the new behavior from my v1, so if 'first_branch' has no tracking branch, then

    git checkout -b first_branch
    git checkout -b new_branch origin/another_branch

falls back to 'new_branch ' tracking 'origin/another_branch' instead? Or not, maybe this fallback is just bad?

Harald
Previous: Phillip WoodNext: Ben Knoble
Message 7 of 8 in “branch: let inherit track a remote-tracking start point”
  1. branch: let inherit track a remote-tracking start pointHarald Nordgren via GitGitGadget, Oct 16, 2026
  2. Junio C HamanoOct 16, 2026
  3. Harald NordgrenOct 17, 2026
  4. Ben KnobleOct 19, 2026
  5. Junio C HamanoOct 19, 2026
  6. Phillip WoodOct 18, 2026
  7. Harald NordgrenOct 18, 2026
  8. Ben KnobleOct 19, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.