git default branch name
rhubert opened this issue · 2 comments
I just stumbled upon this when I tried to clone a newly created repo with bob
. Looks like GitHub, Gitlab,.. changed the default name to main
....
https://about.gitlab.com/blog/2021/03/10/new-git-default-branch-name/
https://github.com/github/renaming
What options do we have?
- leave it
master
- remove
master
and useHEAD
- policy based change from
master
tomain
/HEAD
? - config-variable?
- try
master
first, fallback tomain
? - combination of 2,3,(4) ?
- ...?
I somehow prefer option 2. According to the manual (search for builtins.fetchGit
) nix
uses HEAD
as default.
hmm, the HEAD thing i do not understand.
The special symbol "HEAD" can always be used to refer to the current branch.
https://git-scm.com/docs/user-manual.html
this would change the behavior in some cases. so i guess we should do the policy thing (3).
I kind of incline towards option 4. We could introduce an option in config.yaml
or default.yaml
that sets the default git branch globally. Of course it needs to stay at master
by default to retain backwards compatibility.
The problem with option 2. and 5. is that you don't know in advance what branch you will get. It's also something that may change with time, depending on the server configuration. Some of the earliest versions of Bob did in fact use plain "git clone" if no branch was given. It turned our to be too hard to implement correctly because you will have to handle the case where the default branch on the server is changed and you have to update your working copy accordingly.