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

more useful set-upstream

From
Ramana Kumar <ramana.kumar@gmail.com>
Date
Sep 21, 2010, 08:55 UTC
Message-ID
<AANLkTi=c51u=pQ3TLt3YE54mbwy8AqRb2rcsatEVo2U5@mail.gmail.com>
Is there a better way to achieve the functionality of this alias?
  set-upstream = "!sh -c 'current=$(git symbolic-ref HEAD); git branch
\"$current\" --set-upstream \"$1\"/$(basename $current)' -"
(forgive me if stupid gmail word wrapped that line)
This allows me to write
$ git set-upstream origin
instead of
$ git branch <current branch> --set-upstream origin/<current branch>

which is a pain to write for several reasons: I have to remember the current branch name, that name might be long, and shell autocomplete doesn't know about --set-upstream yet so won't complete the second occurrence.

Having a dedicated script (or git command) rather than an alias would allow
greater functionality like:
 - automatically pick the remote name if there's only one remote,
 - a flag to automatically set upstream on all branches (that having
   matching remotes)

I don't understand why all my branches haven't automatically had the right upstream set anyway - am I missing some configuration of pull and push?

Next: Matthieu Moy
Message 1 of 2 in “more useful set-upstream”
  1. Ramana KumarSep 21, 2010
  2. Matthieu MoySep 21, 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.