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

Re: [question] how can i verify whether a local branch is tracking a remote branch?

From
Jeff King <peff@peff.net>
Date
Apr 6, 2009, 21:25 UTC
Message-ID
<20090406212516.GA882@coredump.intra.peff.net>
In-Reply-To
<4d8e3fd30904060130l985b0a5x331d215ca6106fd4@mail.gmail.com>
On Mon, Apr 06, 2009 at 10:30:21AM +0200, Paolo Ciarrocchi wrote:
Show 10 quoted lines
> I often act like a GIT "evangelist" trying to help friends and
> colleagues in starting using GIT and one of the "complaint" I'm
> getting is that people expect to get this information out of the
> branch command.
> 
> I mean something like:
> $ git branch
>  * foo <-> origin/foo
> 
> What do you think?

Ah. Well, if you just want it for human consumption, that is much easier. :) That information is already shown by "git status":

  $ git status
  # On branch next
  # Your branch is ahead of 'origin/next' by 8 commits.
  ...

"git branch -v" is already looking at the information, but it prints only the "ahead/behind" summary. E.g.,:

  $ git branch -v
    bar    1e0672d [behind 5] some commit
  * baz    dccc1cd [ahead 1, behind 3] other commit
    foo    787d5a8 [ahead 1] another commit
    master a0e632e actual upstream master

It would be pretty trivial to make it do something fancier. The (extremely rough) patch below shows the tracking branch when double-verbosity is given:

  $ git branch -vv
  * next 2d44318 [origin/next: ahead 9] branch -vv wip
So the questions are:
  - is this worth it? The verbose information is already available via
    git status, but only for the current branch.
  - should it be the default with "-v", or require "-vv"? It take up a
    bit of screen real estate, which is already in short supply for
    "branch -v"
  - in both the "status" and "branch" cases, we show nothing if they
    are equivalent. I guess you would want to see
      * next 2d44318 [origin/next] branch -vv wip
    or
      * next 2d44318 [origin/next: uptodate] branch -vv wip
-Peff
Previous: Paolo CiarrocchiNext: Paolo Ciarrocchi
Message 8 of 13 in “[question] how can i verify whether a local branch is tracking a remote branch?”
  1. Paolo CiarrocchiApr 5, 2009
  2. Jeff KingApr 5, 2009
  3. Paolo CiarrocchiApr 5, 2009
  4. Jeff KingApr 6, 2009
  5. Junio C HamanoApr 6, 2009
  6. Jeff KingApr 6, 2009
  7. Paolo CiarrocchiApr 6, 2009
  8. Jeff KingApr 6, 2009
  9. Paolo CiarrocchiApr 6, 2009
  10. Jeff KingApr 7, 2009
  11. Michael J GruberApr 6, 2009
  12. Jeff KingApr 6, 2009
  13. Michael J GruberApr 7, 2009

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.