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

Re: branch --set-upstream considered harmful

From
Jay Soffian <jaysoffian@gmail.com>
Date
Jun 7, 2010, 05:19 UTC
Message-ID
<AANLkTildT6TRd0sPlv1QbCLO7oOPHM-L1yWNIdhdp0ex@mail.gmail.com>
In-Reply-To
<AANLkTikUkkWQl7cYuPiKGaJFYL_JlIGFCXXf7En8t0FN@mail.gmail.com>
On Mon, Jun 7, 2010 at 1:10 AM, Tay Ray Chuan <rctay89@gmail.com> wrote:
Show 5 quoted lines
>>  (topic)$ git branch --set-upstream origin/master
>
> Hmm, I can see where the confusion is coming from - you're treating
> git-branch as a "branch modifier", when it really is a "branch
> creator" - unless you use -f, of course.

Given --set-upstream's implementation and documentation, I assume it is primarily intended to be used with an existing branch:

       --set-upstream
           If specified branch does not exist yet or if --force has been
           given, acts exactly like --track. Otherwise sets up configuration
           like --track would when creating the branch, except that where
           branch points to is not changed.

If it isn't, then there's no way to do what it does other than two magical git config commands.

>>  (topic)$ git branch --set-upstream=origin/master
>>  Branch topic set up to track remote branch master from origin.
>
> I was under the impression that long-style options took "=".

Git is inconsistent. Some do, some don't. But --set-upstream is currently an argumentless switch. If I were to proceed as I suggested, it would be both an argumentless switch and an option which takes an argument. That means these would be equivalent:

$ git branch --set-upstream=origin/master master $ git branch --set-upstream master origin/master

But these WOULD NOT:

$ git branch --set-upstream=origin/master $ git branch --set-upstream origin/master

j.
Previous: Tay Ray ChuanNext: Thomas Rast
Message 3 of 6 in “branch --set-upstream considered harmful”
  1. Jay SoffianJun 6, 2010
  2. Tay Ray ChuanJun 7, 2010
  3. Jay SoffianJun 7, 2010
  4. Thomas RastJun 7, 2010
  5. Jay SoffianJun 7, 2010
  6. Michael J GruberJun 7, 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.