Subject: Re: [PATCH v2] revisions: add @{default} shorthand for default branch

From: "Kristoffer Haugsbakk" <[email-masked]>
Date: Fri, 30 Jan 2026 17:54:19 +0100

On Fri, Jan 30, 2026, at 14:26, Harald Nordgren via GitGitGadget wrote:
> From: Harald Nordgren <[email-masked]>
>
> Git already has shorthands like @{upstream} and @{push} to refer to
> tracking branches, but there is no convenient way to refer to the
> default branch of a repository (typically "main" or "master").

I don’t use a lot of different repositories. But for the two I do use I
use `origin`. (Really `o` since I name the regular remote `o`.) Most of
the time I do not need to have the main *branch* as a branch. I am not
working on the main branch. Using the remote-tracking branch directly is
more convenient.

> Users often want to switch to the default branch regardless of its
> name, especially when working across repositories with different
> default branch names. Currently they must either hardcode the branch
> name or query it via configuration, which is cumbersome.

*Query it* sounds like git-config(1). I have found `git var
GIT_DEFAULT_BRANCH` useful for when I want to answer a question
without hardcodig `main` or `master`.

>
> Add a new @{default} shorthand that resolves to the default branch
> as determined by init.defaultBranch (or falls back to "main" or
> "master" depending on Git version). This allows users to write:
>
>   git checkout @{default}
>
> instead of having to know or look up the default branch name.
>
> The implementation follows the same pattern as @{upstream} and @{push},
> using a new branch_get_default() function that queries the default
> branch name and verifies it exists in the repository.
>
> Signed-off-by: Harald Nordgren <[email-masked]>
> ---
>[snip]