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

Re: get-upstream

From
Pat Notz <patnotz@gmail.com>
Date
Sep 23, 2010, 14:28 UTC
Message-ID
<AANLkTinm2sJbhiZ8pUNtv4KUE3tqWtsDVzKpNXUa=Dn7@mail.gmail.com>
In-Reply-To
<20100923053717.GB27540@sigill.intra.peff.net>
On Wed, Sep 22, 2010 at 11:37 PM, Jeff King <peff@peff.net> wrote:
Show 13 quoted lines
> On Thu, Sep 23, 2010 at 02:16:43PM +1000, Ramana Kumar wrote:
>
>> Thanks Pat - that's awesome.
>> Is there a git shortcut for removing the refs/remotes or refs/heads
>> prefix? (I know I can just use other progs for that too)
>
> If you use the for-each-ref solution, you can use the :short modifier,
> like:
>
>  git for-each-ref --format='%(upstream:short)' `git symbolic-ref HEAD`
>
> -Peff
>

That's pretty cool. Using the >=1.7.0 syntax you can also specify an alternate branch like

$ git rev-parse --symbolic-full-name other-branch@{upstream}

Also, looking at TFM I discovered that @{u} is valid shorthand for @{upstream} -- sweet.

Still, I think Peff's solution looks best and covers more versions of git.
Previous: Jeff KingNext: Jeff King
Message 6 of 7 in “get-upstream”
  1. Ramana KumarSep 23, 2010
  2. Pat NotzSep 23, 2010
  3. Pat NotzSep 23, 2010
  4. Ramana KumarSep 23, 2010
  5. Jeff KingSep 23, 2010
  6. Pat NotzSep 23, 2010
  7. Jeff KingSep 23, 2010

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.