# branch tracking: inherit upstream

2 messages from 2011-07-15 to 2011-07-15. Participants: Pete Wyckoff, Jay Soffian.
Thread: https://gitlist.dev/t/27822

## Pete Wyckoff, 2011-07-15 11:09

Subject: branch tracking: inherit upstream
Message-ID: <20110715110928.GA3425@arf.padd.com>
URL: https://gitlist.dev/e/20110715110928.GA3425%40arf.padd.com

```
At work, our primary SCM is perforce (p4), but many of us use git
in front of that for day-to-day work.  The build system requires
information about what part of the P4 repository it is building.
I've cobbled together changes to make this work with git, and
have been using "git merge-base HEAD @{upstream}" to find the
top-most git-p4 commit.

But @{upstream} is not automatically inherited by branches.  It
is fine when a local branch is a normal tracking branch of
origin/master, like:

    $ git checkout master
    $ git rev-parse --symbolic-full-name @{upstream}
    refs/remotes/origin/master

But I'd also like this to work:

    $ git branch feature
    $ git checkout feature
    $ git rev-parse --symbolic-full-name @{upstream}
    error: No upstream branch found for ''
    @{upstream}
    error: No upstream branch found for ''
    fatal: ambiguous argument '@{upstream}': unknown revision or path not in the working tree.
    Use '--' to separate paths from revisions

I know I can do:

    $ git branch --set-upstream feature origin/master

but that is a pain.  And I know I can track the local master, but
that is not what I want.

I'm looking for something like "branch.autosetupupstream" that
would cause the upstream of new branches to be copied from the
old branch (when it exists).  Does this make sense?

		-- Pete

```

## Jay Soffian, 2011-07-15 15:51

Subject: Re: branch tracking: inherit upstream
Message-ID: <CAG+J_DyxMJtzf2N90vgJjQL1SikUw__KECBhrJWC=SgpYNdG0A@mail.gmail.com>
URL: https://gitlist.dev/e/CAG%2BJ_DyxMJtzf2N90vgJjQL1SikUw__KECBhrJWC%3DSgpYNdG0A%40mail.gmail.com
In-Reply-To: <20110715110928.GA3425@arf.padd.com>

```
On Fri, Jul 15, 2011 at 7:09 AM, Pete Wyckoff <pw@padd.com> wrote:
> At work, our primary SCM is perforce (p4), but many of us use git
> in front of that for day-to-day work.  The build system requires
> information about what part of the P4 repository it is building.
> I've cobbled together changes to make this work with git, and
> have been using "git merge-base HEAD @{upstream}" to find the
> top-most git-p4 commit.
>
> But @{upstream} is not automatically inherited by branches.  It
> is fine when a local branch is a normal tracking branch of
> origin/master, like:
>
>    $ git checkout master
>    $ git rev-parse --symbolic-full-name @{upstream}
>    refs/remotes/origin/master
>
> But I'd also like this to work:
>
>    $ git branch feature
>    $ git checkout feature
>    $ git rev-parse --symbolic-full-name @{upstream}
>    error: No upstream branch found for ''
>    @{upstream}
>    error: No upstream branch found for ''
>    fatal: ambiguous argument '@{upstream}': unknown revision or path not in the working tree.
>    Use '--' to separate paths from revisions
>
> I know I can do:
>
>    $ git branch --set-upstream feature origin/master
>
> but that is a pain.  And I know I can track the local master, but
> that is not what I want.
>
> I'm looking for something like "branch.autosetupupstream" that
> would cause the upstream of new branches to be copied from the
> old branch (when it exists).  Does this make sense?

Yeah, this is something I'd like to fix:

  http://thread.gmane.org/gmane.comp.version-control.git/168157

j.

```
