public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Harald Nordgren <haraldnordgren@gmail.com>, gitster@pobox.com
Cc: git@vger.kernel.org, gitgitgadget@gmail.com
Subject: Re: [PATCH] revisions: add @{default} shorthand for default branch
Date: Mon, 2 Feb 2026 09:37:10 +0000	[thread overview]
Message-ID: <d92bd08f-abee-49a6-89ad-3be5e0c06ad6@gmail.com> (raw)
In-Reply-To: <20260131202232.9213-1-haraldnordgren@gmail.com>

On 31/01/2026 20:22, Harald Nordgren wrote:
>> So in that sense, I do understand why somebody may find it useful if
>> there is a handy short-hand for refs/remotes/origin/main (or
>> whichever branch is pointed at by refs/remotes/origin/HEAD) in the
>> above picture.  And refs/remotes/origin/HEAD already does have a
>> handy short-hand, which is 'origin' ;-).
> 
> 'git checkout origin' doesn't work without resulting in a detached head.

That's expected because it refers to a remote tracking branch. Please 
correct me if I'm wrong but I think maybe what you're asking for is a 
shorthand for the branch "$b" where

	git push origin $b

would update the remote tracking branch pointed to by "origin/HEAD". 
I've not really thought this through but if that is what you want maybe 
we could add "@{local}" to give that branch. Then, with the default 
refspecs and with "origin/HEAD" pointing to "origin/master", 
"origin@{local}" would be "refs/heads/master". If you created a feature 
branch with

	git checkout -b feature origin

and you wanted to merge it into the local branch corresponding to the 
default branch on its upstream remote you could do

	git checkout feature@{upstream}@{local}
	git merge feature

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. Below you say you don't work directly on the 
main branch but then later on you're then creating a release from it. Is 
"main" just a mirror of "origin/main" or are you merging local work into 
it as well?

Thanks

Phillip

>> As Kristoffer said in another message [*1*], I would too expect that
>> people would not work on their 'main' (or have their 'main' track
>> the upstream's 'main').  So the utility of the piping to sed we saw
>> above is dubious, unless we are talking about quite different
>> workflow, but I do not think of what that other workflow would look
>> like that makes a neutral synonym for 'main' useful.
> 
> I don't work directly on the main branch.
> 
> However it serves and the only starting point for creating any new feature
> branches. This is the command I use, and would be nice if it could be
> simplified:
> 
>      git fetch --all
>      git checkout $(git remote | rg '^(origin|upstream)$' | tail -n1)/HEAD -b new_branch
> 
> The main branch is used in my work frontend project for the app release
> command, so there I do
> 
>      git checkout $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
>      yarn release
> 
> I think me as a non-hardcore Git maintainer spend more time in different
> repos than you two do, so maybe the pain of switching between systems is
> more pronounced. That's my motivation for unifying stuff.
> 
> Just for reference, iterating all forked open-source repos on my machine
> these are the different upstream names I work with:
> 
>      99designs/gqlgen
>      refs/remotes/upstream/master
> 
>      amplitude/experiment-react-native-client
>      refs/remotes/upstream/main
> 
>      Antonboom/testifylint
>      refs/remotes/upstream/master
> 
>      cli/cli
>      refs/remotes/upstream/trunk
> 
>      datastax/python-driver
>      refs/remotes/origin/master
> 
>      dependabot/dependabot-core
>      refs/remotes/origin/main
> 
>      derailed/k9s
>      refs/remotes/origin/master
> 
>      elastic/go-elasticsearch
>      refs/remotes/upstream/main
> 
>      git/git
>      refs/remotes/upstream/master
> 
>      gitgitgadget/gitgitgadget
>      refs/remotes/upstream/main
> 
>      github-linguist/linguist
>      refs/remotes/origin/main
> 
>      go-redis/redis_rate
>      refs/remotes/origin/v10
> 
>      golang-migrate/migrate
>      refs/remotes/upstream/master
> 
>      golang/go
>      refs/remotes/origin/master
> 
>      golangci/golangci-lint-action
>      refs/remotes/upstream/main
> 
>      gradle/gradle
>      refs/remotes/origin/master
> 
>      Homebrew/brew
>      refs/remotes/origin/main
> 
>      jwalton/gh-docker-logs
>      refs/remotes/upstream/master
> 
>      Khan/genqlient
>      refs/remotes/upstream/main
> 
>      kubernetes-sigs/controller-tools
>      refs/remotes/origin/main
> 
>      kubernetes/kompose
>      refs/remotes/origin/main
> 
>      kubernetes/kubernetes
>      refs/remotes/origin/master
> 
>      ldez/usetesting
>      refs/remotes/origin/main
> 
>      liushuangls/go-anthropic
>      refs/remotes/upstream/main
> 
>      matryer/moq
>      refs/remotes/upstream/main
> 
>      mhemmings/revenuecat
>      refs/remotes/origin/master
> 
>      ohmyzsh/ohmyzsh
>      refs/remotes/upstream/master
> 
>      prettier/prettier
>      refs/remotes/origin/main
> 
>      RevenueCat/docs
>      refs/remotes/upstream/main
> 
>      RevenueCat/purchases-ios
>      refs/remotes/origin/main
> 
>      RevenueCat/react-native-purchases
>      refs/remotes/origin/main
> 
>      sashabaranov/go-openai
>      refs/remotes/upstream/master
> 
>      stretchr/testify
>      refs/remotes/origin/master
> 
>      vektah/gqlparser
>      refs/remotes/upstream/master
> 
> 
>> Doesn't repo_default_branch_name() do the right thing without being
>> noisy at all even in a repository without that configured, as the
>> function will fall back to the built-in default?  While I do not
>> think of a workflow in which a handy access to the value the
>> function gives would be so useful that it deserves a short-hand, it
>> would be a reasonable candidate of what to be called "@{default}",
>> if it proves useful, I would think.
> 
> I'll play around with this a bit and see how it works. Thanks for the tip!
> 
> 
> Harald
> 


  parent reply	other threads:[~2026-02-02  9:37 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 [this message]
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
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=d92bd08f-abee-49a6-89ad-3be5e0c06ad6@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=haraldnordgren@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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