git branch --delete master

posted on August 4, 12020 HE
topics: hacking, internet

git version 2.28.0, released one week ago, includes a simple but nice new feature:

init: allow setting the default for the initial branch name via the config

What does this mean?

Changing new repositories

When creating a git repository using git init, git will create a default branch for you.1 Traditionally, this branch is called “master”, so git creates this branch and you can begin staging and committing files.

Should you find this name distasteful, you can change the name of the branch at any time. The git invocation to do so is

git branch --move master whatever

As of this newest release, git can do this for you. To set the default branch name to main for all repos your user creates, you will want to edit the so-called global git configuration:

git config --global init.defaultBranch main

Any new repository you initialize will now use the default branch main.

Changing existing repositories

This setting only affects new repositories that you create in the future — but changing an existing repo is not difficult.

From the existing repo, rename the branch:

git branch --move master main

Push your new branch (assuming the remote repository is named “origin”):

git push origin main

Finally, delete the remote’s original branch2:

git push origin --delete master

In three steps you have renamed a git branch without making a big deal out of it, all while avoiding the wrath of internet reactionaries.


  1. This simplification is like Newtonian physics: useful and accurate but not exactly true.↩︎

  2. Some hosts for remote repositories do not appreciate you trying to delete the branch named master. This is the case for both GitLab and GitHub. For these, you will need to use their respective web interfaces.↩︎

more from the friends of danso:

rustc_codegen_gcc: Progress Report #13

July 7

What is rustc_codegen_gcc? rustc_codegen_gcc is a GCC ahead-of-time codegen for rustc, meaning that it can be loaded by the existing rustc frontend, but benefits from GCC by having more architectures supported and having access to GCC’s optimizations. …

via Antoyo's Blog

Learning SSH etc

June 17

I am job searching! Fun times. I also have a weirdly high proportion of friends simultaneously job searching, which is cool because we can discuss interview stuff. This is exactly what led me down the road labelled "learn SSH" - my friend and co-j…

via Heather B-Log

Just: the most reductive word in software development

May 1

(Intentionally provocative title.) Do you use the word “just”? Have you ever said something like “oh, we just need to implement that interface for this new type” or “it’s just a small bash script” or something to that effect? I have, many times, and still …

via Occasionally sane

generated by openring