loading...

re: Replacing master in git VIEW POST

TOP OF THREAD FULL DISCUSSION
re: The Git Development Community is working to at least make the name of the main branch easily configurable, so in not so far future having "main" or...
 

The Git Development Community is working to at least make the name of the main branch easily configurable

What's wrong with it now?

mkdir /tmp/git-init && cd $_
git init && git checkout -b main
git commit -m init --allow-empty
git branch -a
git log --oneline
 

As far as I remember, changing the default branch would be able to be done with command line parameter or a configuration variable

git init --default-branch=main

or

git config branch.default main
# ...
git init
 

Please tell me you're being facetious...

Why would I be? It's as easy as specifying the branch name in your checkout command to change what your default is.

Because you asked what was wrong with a 7-step init process, in response to someone mentioning that the git developers are working on making it a configuration option.

It's not a seven-step process, though, that was just a complete example for illustration. It's as simple as:

git init
git checkout -b main

Or, we can just do

git config --global init.defaultBranch main

once, and never have to worry about it again.

We also don't have to worry about alias syntax, which is terminal-type-dependent, and can include it in provisioning/dotfiles repos and it works regardless of the person's system. :)

This option was, as far as I know, not available at the time of writing the blog post in question, and possibly also when I was writing my comment.

It wasn't available yet (though it was already in the pipeline). I was responding to Max, whose response suggested that the addition wasn't necessary and the then-current workflow was sufficient.

Even if the latest release (with this config option) hadn't been out when I responded with the config, I still would have argued in favor of having it as a config option, with the same arguments of being able to set it once and not have to worry about terminal aliases, etc.

Some comments have been hidden by the post's author - find out more

code of conduct - report abuse