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

How to set a default/fallback upstream for new branches?

From
BSBjörn Steinbrink <bsteinbr@gmail.com>
Date
Jun 30, 2024, 11:16 UTC
Message-ID
<CACPtaxbxZV+DPAboY5ijo6AjbsbQm8ep8twM_Ai18F+OG-bDmw@mail.gmail.com>
Hi folks,

My current git workflow is to have a central repo with a master/main branch that receives pull requests and I create my feature branches with that branch, i.e. origin/HEAD, as their upstream. I push using `git push origin HEAD`, using `--force-with-lease` when necessary due to rebasing.

That way pull/push do exactly what I want. I can update my commit series against upstream development on the main branch and update/replace the feature branch on the central version with my updated version of it.

To have the upstream for new branches set up automatically, I have autoSetupMerge set to "inherit". This works most of the time to get the upstream of a new branch set up correctly. But sometimes I need to work on a feature branch that exists in the central repo, for which I have no local branch head yet, e.g. because I took over from someone else. In that case, "git checkout foo" will not find any upstream to inherit:

    $ git checkout foo
    warning: asked to inherit tracking from 'refs/remotes/origin/foo',
but no remote is set
    Switched to a new branch 'foo'

In that situation, I'd like it to fall back to a default value like `origin/HEAD`.

Is there a way to do that?

Cheers, Björn

Message 1 of 1 in “How to set a default/fallback upstream for new branches?”
  1. Björn SteinbrinkJun 30, 2024

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.