# Git workflow with upstream repository

4 messages from 2010-07-24 to 2010-07-24. Participants: Bradley Wagner, Avery Pennarun.
Thread: https://gitlist.dev/t/24490

## Bradley Wagner, 2010-07-24 00:58

Subject: Git workflow with upstream repository
Message-ID: <AANLkTinyUGLMTQ=ruk69pptDUQ3VyaQ7CwtO+QfeJUVC@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTinyUGLMTQ%3Druk69pptDUQ3VyaQ7CwtO%2BQfeJUVC%40mail.gmail.com

```
Hi, I'm trying to figure out the best way to work with two remote
repositories: one origin and an upstream repository.

Basically, with one remote origin I do 'git fetch' and then a 'git
status' which tells me my status as compared to my remote at which
point I decide wether I want to rebase or pull/merge.

If I'm working with another remote repository 'upstream' that I
perhaps don't have permissions to and then my branches are not
tracking against, how would I do something similar to be able to first
see how my branch compares to the remote and then either rebase or
pull/merge.

Am I missing something in git status that allows me to see my status
as compared to another remote?

```

## Avery Pennarun, 2010-07-24 01:24

Subject: Re: Git workflow with upstream repository
Message-ID: <AANLkTik5U0oh8p42hK-871iwnTA5a66Yj-8pU4xSZS40@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTik5U0oh8p42hK-871iwnTA5a66Yj-8pU4xSZS40%40mail.gmail.com
In-Reply-To: <AANLkTinyUGLMTQ=ruk69pptDUQ3VyaQ7CwtO+QfeJUVC@mail.gmail.com>

```
On Fri, Jul 23, 2010 at 8:58 PM, Bradley Wagner
<bradley.wagner@hannonhill.com> wrote:
> If I'm working with another remote repository 'upstream' that I
> perhaps don't have permissions to and then my branches are not
> tracking against, how would I do something similar to be able to first
> see how my branch compares to the remote and then either rebase or
> pull/merge.

# show the commits in my local branch that aren't in upstream
git log upstream/master..

# show the commits in upstream that aren't in my local branch
git log ..upstream/master

# a cuter way to show the commits in upstream that aren't in my local branch
git shortlog ..upstream/master

# summarize the differences in upstream since we diverged (not
including my own changes)
git diff --stat upstream/master..

# summarize the differences between my branch and upstream (including
my changes and theirs)
# (note: three dots)
git diff --stat ...upstream/master

Have fun,

Avery

```

## Bradley Wagner, 2010-07-24 01:43

Subject: Re: Git workflow with upstream repository
Message-ID: <AANLkTi=82NDSfizCCjoJ-Sj05DzwXfa35ro60MiWSQdz@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTi%3D82NDSfizCCjoJ-Sj05DzwXfa35ro60MiWSQdz%40mail.gmail.com
In-Reply-To: <AANLkTik5U0oh8p42hK-871iwnTA5a66Yj-8pU4xSZS40@mail.gmail.com>

```
Thanks, I'll check those out! So, I take it there is not a way to get
a simple message like what git status tells you when you're local
branch is behind the remote branch:

"Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded."

Is there even a concept of a fast-forward merge when pulling from a
remote repo that is not the remote to which your branches are
tracking?

Is it possible to rebase based on a branch that is *not* the branch
you're currently tracking? Is that what the --onto flag is for?

- Bradley

On Jul 23, 2010, at 9:24 PM, Avery Pennarun <apenwarr@gmail.com> wrot
> On Fri, Jul 23, 2010 at 8:58 PM, Bradley Wagner
> <bradley.wagner@hannonhill.com> wrote:
>> If I'm working with another remote repository 'upstream' that I
>> perhaps don't have permissions to and then my branches are not
>> tracking against, how would I do something similar to be able to first
>> see how my branch compares to the remote and then either rebase or
>> pull/merge.
>
> # show the commits in my local branch that aren't in upstream
> git log upstream/master..
>
> # show the commits in upstream that aren't in my local branch
> git log ..upstream/master
>
> # a cuter way to show the commits in upstream that aren't in my local branch
> git shortlog ..upstream/master
>
> # summarize the differences in upstream since we diverged (not
> including my own changes)
> git diff --stat upstream/master..
>
> # summarize the differences between my branch and upstream (including
> my changes and theirs)
> # (note: three dots)
> git diff --stat ...upstream/master
>
> Have fun,
>
> Avery

```

## Avery Pennarun, 2010-07-24 02:39

Subject: Re: Git workflow with upstream repository
Message-ID: <AANLkTi=dgjoa8c=UN1VvMDgo_RAptTr1YFk+n_7M9sdM@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTi%3Ddgjoa8c%3DUN1VvMDgo_RAptTr1YFk%2Bn_7M9sdM%40mail.gmail.com
In-Reply-To: <AANLkTi=82NDSfizCCjoJ-Sj05DzwXfa35ro60MiWSQdz@mail.gmail.com>

```
On Fri, Jul 23, 2010 at 9:43 PM, Bradley Wagner
<bradley.wagner@hannonhill.com> wrote:
> Thanks, I'll check those out! So, I take it there is not a way to get
> a simple message like what git status tells you when you're local
> branch is behind the remote branch:
>
> "Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded."

As far as I know, any given branch can only "track" one particular
branch, and that message is only generated relative to the branch
you're tracking.  You can adjust which one you're tracking by editing
.git/config.

> Is there even a concept of a fast-forward merge when pulling from a
> remote repo that is not the remote to which your branches are
> tracking?

Yes.  Tracking branches are really just a notational convenience.  In
fact, they don't do very much more than generating the above message.
(The other thing they do is make 'git pull' do something by default
when you don't give it any other parameters.)

You might enjoy this article:
http://eagain.net/articles/git-for-computer-scientists/

> Is it possible to rebase based on a branch that is *not* the branch
> you're currently tracking? Is that what the --onto flag is for?

Yes, it's possible.  The question of when you do or don't need the
--onto option is a little more complex than that, but yes, that's
what's it's for, more or less.

Have fun,

Avery

```
