Re: [PATCH] revisions: add @{default} shorthand for default branch
- From
Harald Nordgren <haraldnordgren@gmail.com>
- Date
- Feb 2, 2026, 10:14 UTC
- Message-ID
- <20260202101445.13790-1-haraldnordgren@gmail.com>
- In-Reply-To
- <d92bd08f-abee-49a6-89ad-3be5e0c06ad6@gmail.com>
> 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 didn't realize I was so bad at explaining 😅
What I want is a shorthand for switching to the local version of the default branch of the repo. This but with less voodoo:
git switch $(git rev-parse --abbrev-ref $(git remote | rg '^(origin|upstream)$' | tail -n1) | sed 's@.*/@@')
> 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?
My main is a mirror of upstream/main. I never commit to it, just do 'git pull' to create releases.
Also, I switch to it when I discover a bug on my branch, to try to understand if the bug is already on main or not. It's the baseline all work is compared against.
Show 11 quoted lines
>> 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
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'Harald