From: D. Ben Knoble Date: Mon, 02 Feb 2026 19:40:38 GMT Subject: Re: [PATCH] revisions: add @{default} shorthand for default branch Message-ID: In-Reply-To: <20260202101445.13790-1-haraldnordgren@gmail.com> On Mon, Feb 2, 2026 at 5:19 AM 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 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. > > >> 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 If you don't need to be on a branch, then "git switch -d origin" (or upstream, or whatever your remote is) should work just fine. That just makes discovering the name of the remote the "interesting" part… -- D. Ben Knoble