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
TTarmigan <tarmigan+git@gmail.com>
Date
Aug 9, 2008, 21:56 UTC
Message-ID
<905315640808091456q63c20dcfp9ab3b93387688693@mail.gmail.com>
In-Reply-To
<alpine.DEB.1.00.0808092302520.24820@pacific.mpi-cbg.de.mpi-cbg.de>

On Sat, Aug 9, 2008 at 2:08 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 33 quoted lines
> Hi,
>
> On Sat, 9 Aug 2008, Junio C Hamano wrote:
>
>> Junio C Hamano <gitster@pobox.com> writes:
>>
>> > Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> >
>> >> What does the user most likely want with this command?
>> >>
>> >>    $ git checkout --track origin/next
>> >>
>> >> Exactly.  A branch called 'next', that tracks origin's branch 'next'.
>> >
>> > I like this.
>> >
>> > An explicit --track request from the command line (as opposed to
>> > happening to have "branch.autosetupmerge" configuration) is a very
>> > good cue that what the user wants to do is not to take a peek on a
>> > detached HEAD but a more permanent playpen created.
>>
>> A couple more thoughts.
>
> At first, I liked the thoughts, but...
>
>> (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".

Could we check whether there is already a remote called "origin" with a branch called "next"? If refs/remotes/origin/next exists it could be confusing to create refs/heads/origin/next anyway, so it this dwim might eliminate a problem as well as be nicer. In fact, git soon complains (rightly) about ambigiuos references in this case.

> So it would change the current behavior would, breaking people's habits (I
> do "git checkout -b bla" a lot when I realize that I want to have the
> current changes on a new branch).

If we did this dwim only for remotes, your desired behavior could still work, right?. The default is to --track for branches created from remotes anyway, right?

Thanks, Tarmigan

Previous: Junio C Hamano
Message 10 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.