# [SCRIPT] git-upstream: prints the tracking chain starting at the named ref

2 messages from 2008-07-26 to 2008-07-26. Participants: Scott Collins, Petr Baudis.
Thread: https://gitlist.dev/t/14691

## Scott Collins, 2008-07-26 14:44

Subject: [SCRIPT] git-upstream: prints the tracking chain starting at the named ref
Message-ID: <26F09105-BFA2-4FA2-86AA-B9E6F9DE3762@slashdot.org>
URL: https://gitlist.dev/e/26F09105-BFA2-4FA2-86AA-B9E6F9DE3762%40slashdot.org

```
Howdy, all.

Here's a script I've sort of `grown' over the past few weeks.

I use it to quickly see where a tracking branch stands with respect to  
upstream refs _without_ actually fetching or even switching to the  
tracking branch.  This may not be useful for everyones' work-flows;  
but I find it handy. I'm posting because it may be of use to others  
(and feedback, if any, can only improve it).

Example:

	$ git upstream -v --abbrev master
	ce567d1... master* is behind 'origin/master' by 17 commits, and can  
be fast-forwarded.
	186458b... origin/master
	186458b... master@origin, git://git.kernel.org/pub/scm/git/git.git

For more info, try: git upstream -v -h

It's a perl script and uses Git.pm.  Tries to fit into git standard  
practices.  Supports colors (defaults to color like git branch),  
configs.  It has a few rough edges, but it's very usable.  The tiny  
pause before printing a remote tracking branch is ls-remote.  I hope  
the name doesn't conflict with anything.

I apologize for attaching rather than inserting in-line; but this is a  
complete file, not a patch and I also don't trust my mailer :-(







hopefully someone else finds this useful :-)
_____________
Scott Collins
```

## Petr Baudis, 2008-07-26 16:39

Subject: Re: [SCRIPT] git-upstream: prints the tracking chain starting at the named ref
Message-ID: <20080726163954.GA32184@machine.or.cz>
URL: https://gitlist.dev/e/20080726163954.GA32184%40machine.or.cz
In-Reply-To: <26F09105-BFA2-4FA2-86AA-B9E6F9DE3762@slashdot.org>

```
  Hi,

On Sat, Jul 26, 2008 at 10:44:29AM -0400, Scott Collins wrote:
> Here's a script I've sort of `grown' over the past few weeks.
>
> I use it to quickly see where a tracking branch stands with respect to 
> upstream refs _without_ actually fetching or even switching to the tracking 
> branch.  This may not be useful for everyones' work-flows; but I find it 
> handy. I'm posting because it may be of use to others (and feedback, if 
> any, can only improve it).

  I wonder why is it a problem to fetch first in your workflow? If there
is nothing for a fetch, git-upstream is going to be as fast as git fetch
&& git branch, if there is something for a fetch, you probably want to
fetch anyway if you're running this script.

  Note that in very recent Git trees, git branch -v will show some
tracking information, however it could use quite some improvement (print
something even if the branch equals the remote branch, print the
ahead/behind combination in case the branch does not fast-forward) -
maybe it might be more effective to enhance that instead?

-- 
				Petr "Pasky" Baudis
As in certain cults it is possible to kill a process if you know
its true name.  -- Ken Thompson and Dennis M. Ritchie

```
