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

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

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Feb 3, 2026, 14:38 UTC
Message-ID
<9120dbf3-f10f-4333-aa70-f24835d7ef02@gmail.com>
In-Reply-To
<20260202101445.13790-1-haraldnordgren@gmail.com>
On 02/02/2026 10:14, 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.
 >
Show 18 quoted lines
> 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'

I think I understand now. That sounds tricky to do in the general case because we don't know what the remote is called. "origin" and "upstream" are popular choices but the user can choose any name they want when they run "git clone" (or rename the remote after they clone). If there is only one remote then its simple because there is only one choice. It's also simple if there are multiple remotes and they all use the same default branch name and refspecs. If remote.pushDefault is set we can probably rule that remote out. If there's a branch checked out with an upstream set we could use that remote but there's no guarantee that's the remote the user wants. I don't think there's a robust way to determine the remote the user wants in the general case.

With the "@{local}" thing I suggested yesterday the user would have to name the remote which makes everything well defined but I think you want to avoid having to do that.

Thanks
Phillip
Previous: Harald NordgrenNext: Junio C Hamano
Message 27 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.