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

Re: [PATCH] checkout --track: make up a sensible branch name if '-b' was omitted

From
PBPieter de Bie <pieter@frim.nl>
Date
Aug 9, 2008, 21:44 UTC
Message-ID
<A6E466C6-C3B5-40EB-940C-516CF4D02ADF@frim.nl>
In-Reply-To
<7vsktd51wg.fsf@gitster.siamese.dyndns.org>
On Aug 9, 2008, at 11:11 PM, Junio C Hamano wrote:
Show 13 quoted lines
>>> (1) You may not necessarily are used to --track, but may still  
>>> want this
>>>    done.  It might not be a bad idea to associate this "local  
>>> dwimming"
>>>    to creation of a new branch.  In other words, all of these:
>>>
>>>    $ git checkout -b origin/next
>>
>> This cannot be dwimmed, as it literally means "start a new branch  
>> called
>> 'origin/next' from HEAD".
>
> Right.  Forget this part.
This is too bad. I often see people make mistakes like
	git checkout -b origin/master
or
	git checkout -b origin/master origin/master
which should be
	git checkout -b origin/master master

I think both forms should at least be an error if the remote branch "origin/master" already exists, as then suddenly they aren't reachable anymore by using "origin/master".

Changing the behaviour to mean "git checkout -b origin/master master" will change the meaning, but who uses -b with an existing remote branch anyway? I think the current behaviour leads to more confusion in every case and should at least error out ("Error: creating a local repository with the same name as the remote is not allowed") or do what it's meant to do, which is create a local repository with the trailing part.

Just my .02,
- Pieter
Previous: Junio C HamanoNext: Johannes Schindelin
Message 6 of 10 in “checkout --track: make up a sensible branch name if '-b' was omitted”
  1. checkout --track: make up a sensible branch name if '-b' was omittedJohannes Schindelin, Aug 9, 2008
  2. Junio C HamanoAug 9, 2008
  3. Junio C HamanoAug 9, 2008
  4. Johannes SchindelinAug 9, 2008
  5. Junio C HamanoAug 9, 2008
  6. Pieter de BieAug 9, 2008
  7. Johannes SchindelinAug 10, 2008
  8. Johannes SchindelinAug 11, 2008
  9. Junio C HamanoAug 11, 2008
  10. TarmiganAug 9, 2008

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.