git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Phillip WoodNext: D. Ben Knoble
Message 15 of 32 in “revisions: add @{default} shorthand for default branch”
  1. revisions: add @{default} shorthand for default branchHarald Nordgren via GitGitGadget, Jan 29, 2026
  2. Junio C HamanoJan 29, 2026
  3. Harald NordgrenJan 30, 2026
  4. Harald NordgrenJan 30, 2026
  5. Junio C HamanoJan 30, 2026
  6. Harald NordgrenJan 30, 2026
  7. Junio C HamanoJan 30, 2026
  8. Harald NordgrenJan 31, 2026
  9. Junio C HamanoJan 31, 2026
  10. Harald NordgrenJan 31, 2026
  11. Harald NordgrenJan 31, 2026
  12. Junio C HamanoFeb 2, 2026
  13. Harald NordgrenFeb 2, 2026
  14. Phillip WoodFeb 2, 2026
  15. Harald NordgrenFeb 2, 2026
  16. D. Ben KnobleFeb 2, 2026
  17. Harald NordgrenFeb 2, 2026
  18. Kristoffer HaugsbakkFeb 2, 2026
  19. Ben KnobleFeb 2, 2026
  20. Harald NordgrenFeb 2, 2026
  21. Junio C HamanoFeb 2, 2026
  22. Ben KnobleFeb 2, 2026
  23. Harald NordgrenFeb 2, 2026
  24. Junio C HamanoFeb 2, 2026
  25. Harald NordgrenFeb 2, 2026
  26. Harald NordgrenFeb 3, 2026
  27. Phillip WoodFeb 3, 2026
  28. Junio C HamanoFeb 2, 2026
  29. revisions: add @{default} shorthand for default branchHarald Nordgren via GitGitGadget, Jan 30, 2026
  30. Kristoffer HaugsbakkJan 30, 2026
  31. revisions: add @{primary} shorthand for primary branchHarald Nordgren via GitGitGadget, Jan 30, 2026
  32. revisions: add @{primary} shorthand for primary branchHarald Nordgren via GitGitGadget, Jan 31, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.