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

1 messages from 2024-06-30 to 2024-06-30. Participants: Björn Steinbrink.
Thread: https://gitlist.dev/t/61706

## Björn Steinbrink, 2024-06-30 11:16

Subject: How to set a default/fallback upstream for new branches?
Message-ID: <CACPtaxbxZV+DPAboY5ijo6AjbsbQm8ep8twM_Ai18F+OG-bDmw@mail.gmail.com>
URL: https://gitlist.dev/e/CACPtaxbxZV%2BDPAboY5ijo6AjbsbQm8ep8twM_Ai18F%2BOG-bDmw%40mail.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

```
