{"thread":{"id":"59644","subject":"Reference the master/main branch with @{m}","startedAt":"2023-04-24T15:12:30Z","lastAt":"2023-04-24T15:45:30Z","messageCount":2,"participants":["Xavier Roche","Felipe Contreras"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"475920","messageId":"CAE9vp3+_PB0_rA81eWVCF=iXnWjrUVY=1G3=1JPUbcaw2u95Rg@mail.gmail.com","threadId":"59644","inReplyTo":null,"subject":"Reference the master/main branch with @{m}","fromName":"Xavier Roche","fromEmail":"xavier.roche@algolia.com","sentAt":"2023-04-24T15:11:29Z","receivedAt":"2023-04-24T15:12:30Z","isPatch":false,"sender":{"key":"xavier.roche@algolia.com","avatar":null},"body":"With git, you can reference the upstream branch with the @{upstream}\nor @{u} shorthand\n(https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches)\n\nWith master/main branch varying among repositories, it would be handy\nto have a \"main/master\" reference, such as @{main} or @{m}\n\nWould that make sense?\n\n-- \nXavier Roche -\nxavier.roche@algolia.com\n"},{"id":"475926","messageId":"6446a415925b2_393129470@chronos.notmuch","threadId":"59644","inReplyTo":"CAE9vp3+_PB0_rA81eWVCF=iXnWjrUVY=1G3=1JPUbcaw2u95Rg@mail.gmail.com","subject":"Re: Reference the master/main branch with @{m}","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2023-04-24T15:45:25Z","receivedAt":"2023-04-24T15:45:30Z","isPatch":false,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Xavier Roche wrote:\n> With git, you can reference the upstream branch with the @{upstream}\n> or @{u} shorthand\n> (https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches)\n> \n> With master/main branch varying among repositories, it would be handy\n> to have a \"main/master\" reference, such as @{main} or @{m}\n> \n> Would that make sense?\n\nNo, it would not make sense.\n\nThe `@{upstream}` mark is itself a shorthand for `HEAD@{upstream}`, so it\ndepends on the value of `HEAD`. For example if the current branch is is\n\"hot-fix-1\", \"@{upstream}\" could be \"master\", but if the current branch is\n\"feature-1\", \"@{upstream}\" could be \"dev\": \"hot-fix-1@{upstream}\" !=\n\"feature-1@{upstream}\".\n\n`HEAD@{m}` does not make sense, because it would be the same for all branches.\n\nWe could have a \"DEFAULT\" pseudo-branch, or maybe even \"default\", but this is\nnot necessary, because that's something that you can already achieve.\n\nYour personal local repository does not have to mirror the remote repository.\n\nYou can have a local \"default\" branch whose upstream branch is \"master\" or\n\"main\" (depending on the remote).\n\nThis is what I do. If I clone a repository that uses \"main\", I simply rename\nthe default branch in my local repository to \"master\".\n\nArguably this is something that `git clone` should do by default: if I have\nconfigured `init.defaultbranch=master`, `git clone` should do `git clone -b\nmaster` by default.\n\nEither way, doing `git branch -m master` in the tiny minority of repos that\ndon't use \"master\" as the default branch seems like a marginal effort to me.\n\nCheers.\n\n-- \nFelipe Contreras\n"}]}