DEV Community

Discussion on: Replacing master in git

goodevilgenius profile image
Dan Jones

I've been thinking about the name since this discussion recently started, and it occurred to me that there's another reason why master (as well as main, primary, trunk, etc.) aren't really appropriate for the default branch.

One of the main design intentions of Linus Torvalds while he was developing git is to be nothing like subversion. svn uses trunk, with the idea that everything else "branches" out from there. git is not like that. In fact, "branch" is a poor choice of words for git, because it implies that there is a trunk, however, in git, there is no trunk at all. There's nothing special about the default branch. It's just another branch. They just needed a name for the first branch. But they were thinking in terms they were used to, like in BitKeeper, or Subversion. So, they called it master, reasoning that it would be the primary branch. But, it's not the primary branch, it's just the first one.

And in hosted git repos, like GitHub, the "default" branch is simply whichever branch HEAD points to. That's what GitHub does when you change your default branch: it just points to whichever one you specify. And when you clone a repo from a remote source, unless you specify otherwise, your local HEAD will start whatever HEAD is on the remote.

People use git like that (with a tree-like branching pattern), though, so it works for most people. But not everyone uses git like that. There are plenty of projects that maintain multiple primary branches, mainly to keep development going on older versions.

So, with the idea that really every branch is just a branch, they should, ideally, be named according to their function. So, my suggestion is that the "default" branch would be prod, or production. That way, it's clear that this branch has production-ready code. If you follow the git flow style, this makes sense anyway. You do most of your work in develop and feature branches, and merge into prod when it's ready.

daniero profile image
Daniel Rødskog • Edited

That way, it's clear that this branch has production-ready code

What if it's not code that I'm keeping in my repo? For example I kept my master principal thesis in git. At that time, still in school, I felt no connection to the word prod at all. I think the premise for this discussion is absurd, but if I had to pick a new word, it would have to be as generic as possible. I think main works well.

goodevilgenius profile image
Dan Jones

"As generic as possible" would probably be "default", because that's all it is. It's the default branch.

It might be for production code. It might be for in-development code. It might be for documentation. It might be for something completely different.

Folks using git should choose a name for their first branch that accurately reflects what the branch is being used for. That way it's not ambiguous.

And if you're using it just for yourself, and not using it for collaboration, so it doesn't matter what you call it, call it whatever you want. It doesn't affect anybody else. It only has to have meaning to you.

shaunagordon profile image
Shauna Gordon

What if it's not code that I'm keeping in my repo?

While "production" may not be a 100% accurate word (and is why different people have different ideas for the default name), the concept is still the same -- that's the rendition that's going to ultimately go to the final audience (be it client computers or bookshelves).

Weirdly enough, all of this disagreement could be solved by making the default branch name a config option...

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