Re: Reference the master/main branch with @{m}

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux