From: Felipe Contreras <felipe.contreras@gmail.com>
To: Xavier Roche <xavier.roche@algolia.com>, git@vger.kernel.org
Subject: Re: Reference the master/main branch with @{m}
Date: Mon, 24 Apr 2023 09:45:25 -0600 [thread overview]
Message-ID: <6446a415925b2_393129470@chronos.notmuch> (raw)
In-Reply-To: <CAE9vp3+_PB0_rA81eWVCF=iXnWjrUVY=1G3=1JPUbcaw2u95Rg@mail.gmail.com>
Xavier Roche wrote:
> With git, you can reference the upstream branch with the @{upstream}
> or @{u} shorthand
> (https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches)
>
> With master/main branch varying among repositories, it would be handy
> to have a "main/master" reference, such as @{main} or @{m}
>
> Would that make sense?
No, it would not make sense.
The `@{upstream}` mark is itself a shorthand for `HEAD@{upstream}`, so it
depends on the value of `HEAD`. For example if the current branch is is
"hot-fix-1", "@{upstream}" could be "master", but if the current branch is
"feature-1", "@{upstream}" could be "dev": "hot-fix-1@{upstream}" !=
"feature-1@{upstream}".
`HEAD@{m}` does not make sense, because it would be the same for all branches.
We could have a "DEFAULT" pseudo-branch, or maybe even "default", but this is
not necessary, because that's something that you can already achieve.
Your personal local repository does not have to mirror the remote repository.
You can have a local "default" branch whose upstream branch is "master" or
"main" (depending on the remote).
This is what I do. If I clone a repository that uses "main", I simply rename
the default branch in my local repository to "master".
Arguably this is something that `git clone` should do by default: if I have
configured `init.defaultbranch=master`, `git clone` should do `git clone -b
master` by default.
Either way, doing `git branch -m master` in the tiny minority of repos that
don't use "master" as the default branch seems like a marginal effort to me.
Cheers.
--
Felipe Contreras
prev parent reply other threads:[~2023-04-24 15:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-24 15:11 Reference the master/main branch with @{m} Xavier Roche
2023-04-24 15:45 ` Felipe Contreras [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6446a415925b2_393129470@chronos.notmuch \
--to=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=xavier.roche@algolia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).