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

Re: [PATCH] checkout: add remoteBranchTemplate config for DWIM branch names

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 22, 2025, 04:40 UTC
Message-ID
<xmqqtsxjruwi.fsf@gitster.g>
In-Reply-To
<pull.2136.git.git.1766332796836.gitgitgadget@gmail.com>
"Pasteley Absurda via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 13 quoted lines
> From: pasteley <ceasebeing@gmail.com>
>
> Add checkout.remoteBranchTemplate to apply a template pattern when
> searching for remote branches during checkout DWIM and when creating
> remote branches with push.autoSetupRemote.
>
> Template uses printf-style placeholders (%s for branch name). For
> example, with "feature/%s", checking out "foo"
> searches for "origin/feature/foo" and creates local "foo"
> tracking it. Pushing with autoSetupRemote creates "origin/feature/bar"
> from local "bar".
>
> Useful when remote branches use prefixes but local branches don't.

It fells that this is presented backwards. The usefulness of the layout that names local branches deliberately differently from their remote counterparts needs to be justified first. Only after that, we can consider adding extra mechanism to support such a layout.

Once "git checkout foo" is taught to do the same as "git checkout -b extra-foo -t origin/foo", it would create

	[branch "extra-foo"] 
		remote = origin
		merge = refs/heads/foo

but the push side would need extra work, and that is why you needed to muck with the push refspec. But then what should happen when the user is using "we do not bother remembering what branches to push there; the remote repository remembers that for us", aka "matching push"?

Most of the problems is what you are creating by using an unusual layout to name local branches differently from the remote counterpart. You do not have to, and then all the problems you created with that layout goes away, without this patch.

So, I am not sure if this is a good idea to begin with. At least, I am not yet convinced.

Thanks.
Previous: Pasteley Absurda via GitGitGadgetNext: pasteley
Message 2 of 5 in “checkout: add remoteBranchTemplate config for DWIM branch names”
  1. checkout: add remoteBranchTemplate config for DWIM branch namesPasteley Absurda via GitGitGadget, Dec 21, 2025
  2. Junio C HamanoDec 22, 2025
  3. pasteleyDec 22, 2025
  4. Junio C HamanoDec 23, 2025
  5. pasteleyDec 23, 2025

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.