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

get-upstream

From
Ramana Kumar <ramana.kumar@gmail.com>
Date
Sep 23, 2010, 03:46 UTC
Message-ID
<AANLkTikqJmsUo53dRngXcWsoEfcFzLQ-J1V5oZOGUL03@mail.gmail.com>

Is there an easy command to get a symbolic reference to the upstream branch of a tracking branch?

For example, to get the current branch name I can do this:

$ git symbolic-ref HEAD refs/heads/mybranchname

Now I can see the upstream name as follows

$ git branch -vv branch1 ... mybranchname sha [upstreamname: ahead n] ... branch3 ...

My question is is there a way to get upstreamname directly to stdout, similar to the symbolic-ref command?

(I don't want to have to type it manually; tab completion helps a little, but looking for more. Plus this would be necessary to avoid scraping in a script.)

Next: Pat Notz
Message 1 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.