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:29 UTC
Message-ID
<20090406212935.GB882@coredump.intra.peff.net>
In-Reply-To
<49D9EEE2.3000607@drmicha.warpmail.net>
On Mon, Apr 06, 2009 at 02:00:34PM +0200, Michael J Gruber wrote:
Show 13 quoted lines
> > +		if (!strcmp(name, "tracking")) {
> > +			struct branch *branch;
> > +			if (prefixcmp(ref->refname, "refs/heads/"))
> > +				continue;
> > +			branch = branch_get(ref->refname + 11);
> > +			if (branch && branch->merge && branch->merge[0] &&
> > +			    branch->merge[0]->dst)
> > +				v->s = branch->merge[0]->dst;
> 
> Isn't that missing out on those cases where you --track (i.e. follow) a
> local (upstream) branch? See
> 5e6e2b4 (Make local branches behave like remote branches when --tracked,
> 2009-04-01)
I thought the logic was in branch_get to handle it. And indeed:
  $ git checkout --track -b new master
  Branch new set up to track local branch master.
  Switched to a new branch "new"
  $ git for-each-ref --format='%(refname) %(tracking)'
  refs/heads/master
  refs/heads/new refs/heads/master

So it will point either to something in refs/remotes or in refs/heads, as applicable.

> If we hook it up into git-branch there would be to useful directions:

The difference being that git-branch is porcelain and git-for-each-ref is plumbing. So they really serve different purposes.

> - "git branch --follows foo" could list all branches which follow foo,
> analogous to --contains. It gives you all your feature work on top of
> foo, all branches affected by rebasing foo etc.
Sure, that would probably be useful.
> - "git branch --whatever foo" could list the branch whoch foo follows.
> 
> I just notices that "git branch -v foo" does not give me the "-v" output
> for foo... Improving that would open up the possibility to go for -vv foo.
See the "-vv" patch I just posted elsewhere in the thread.
-Peff
Previous: Michael J GruberNext: Michael J Gruber
Message 12 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.