From: Phillip Wood <phillip.wood123@gmail•com>
To: Harald Nordgren <haraldnordgren@gmail•com>
Cc: git@vger•kernel.org, gitgitgadget@gmail•com, gitster@pobox•com,
phillip.wood@dunelm•org.uk
Subject: Re: [PATCH] revisions: add @{default} shorthand for default branch
Date: Tue, 3 Feb 2026 14:38:48 +0000 [thread overview]
Message-ID: <9120dbf3-f10f-4333-aa70-f24835d7ef02@gmail.com> (raw)
In-Reply-To: <20260202101445.13790-1-haraldnordgren@gmail.com>
On 02/02/2026 10:14, Harald Nordgren wrote:
>> I don't really understand what you're trying to achieve and I'm not sure
>> if the suggestion above is a good idea but it might help understand what
>> it is you're trying to do.
>
> I want a shorthand so that when in any of these repos, I'm switching to the
> default branch, I simply have to run
>
> git switch @{primary}
>
> and I would end up with
>
> 99designs/gqlgen
> Switched to branch 'master'
>
> amplitude/experiment-react-native-client
> Switched to branch 'main'
>
> Antonboom/testifylint
> Switched to branch 'main'
>
> cli/cli
> Switched to branch 'trunk'
I think I understand now. That sounds tricky to do in the general case
because we don't know what the remote is called. "origin" and "upstream"
are popular choices but the user can choose any name they want when they
run "git clone" (or rename the remote after they clone). If there is
only one remote then its simple because there is only one choice. It's
also simple if there are multiple remotes and they all use the same
default branch name and refspecs. If remote.pushDefault is set we can
probably rule that remote out. If there's a branch checked out with an
upstream set we could use that remote but there's no guarantee that's
the remote the user wants. I don't think there's a robust way to
determine the remote the user wants in the general case.
With the "@{local}" thing I suggested yesterday the user would have to
name the remote which makes everything well defined but I think you want
to avoid having to do that.
Thanks
Phillip
next prev parent reply other threads:[~2026-02-03 14:38 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-29 15:25 [PATCH] revisions: add @{default} shorthand for default branch Harald Nordgren via GitGitGadget
2026-01-29 20:23 ` Junio C Hamano
2026-01-30 10:59 ` Harald Nordgren
2026-01-30 11:12 ` Harald Nordgren
2026-01-30 16:42 ` Junio C Hamano
2026-01-30 20:58 ` Harald Nordgren
2026-01-30 21:56 ` Junio C Hamano
2026-01-31 0:09 ` Harald Nordgren
2026-01-31 19:16 ` Junio C Hamano
2026-01-31 20:22 ` Harald Nordgren
2026-01-31 20:55 ` Harald Nordgren
2026-02-02 12:32 ` Junio C Hamano
2026-02-02 15:30 ` Harald Nordgren
2026-02-02 9:37 ` Phillip Wood
2026-02-02 10:14 ` Harald Nordgren
2026-02-02 19:40 ` D. Ben Knoble
2026-02-02 21:19 ` Harald Nordgren
2026-02-02 21:53 ` Kristoffer Haugsbakk
2026-02-02 22:17 ` Ben Knoble
2026-02-02 22:54 ` Harald Nordgren
2026-02-02 21:33 ` Junio C Hamano
2026-02-02 22:16 ` Ben Knoble
2026-02-02 23:03 ` Harald Nordgren
2026-02-02 21:44 ` Junio C Hamano
2026-02-02 22:56 ` Harald Nordgren
2026-02-03 11:18 ` Harald Nordgren
2026-02-03 14:38 ` Phillip Wood [this message]
2026-02-02 22:28 ` Junio C Hamano
2026-01-30 13:26 ` [PATCH v2] " Harald Nordgren via GitGitGadget
2026-01-30 16:54 ` Kristoffer Haugsbakk
2026-01-30 20:45 ` [PATCH v3] revisions: add @{primary} shorthand for primary branch Harald Nordgren via GitGitGadget
2026-01-31 0:06 ` [PATCH v4] " Harald Nordgren via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9120dbf3-f10f-4333-aa70-f24835d7ef02@gmail.com \
--to=phillip.wood123@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=gitgitgadget@gmail$(echo .)com \
--cc=gitster@pobox$(echo .)com \
--cc=haraldnordgren@gmail$(echo .)com \
--cc=phillip.wood@dunelm$(echo .)org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox