Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What will break if I don't have a git master branch?

Tags:

git

Most git repositories have a master branch, but there's really nothing special about this name. You can delete the master branch, rename another branch to master, skip having the master branch altogether.

Is anything in git hardcoded to expect a master branch? If I have a repository that doesn't have a branch with this name, is there anything I can expect to work improperly?

like image 349
skiphoppy Avatar asked Apr 02 '09 19:04

skiphoppy


People also ask

Can we have git without master branch?

Master and branch makes no difference for git. So you can use git without a master.

Why does my git branch have no master?

If your first (default) branch is not named "master", the remote/origin/HEAD doesn't seem to be set. Steps to reproduce : Create a new project. Prepare your local repo : git init, add your files, commit locally and add your origin.

Why you should not commit to master?

Not committing to master prevents colliding commits and having to merge each time 2 people change the same file.

Is master branch created automatically?

It's the first branch to be created automatically when you create a new repository. By default, this initial branch is named master .


2 Answers

You don't have to have a master branch, but you should probably set HEAD to a branch that exists even on a bare repository. HEAD is used to determine which branch to checkout by default by git clone.

like image 133
CB Bailey Avatar answered Sep 21 '22 03:09

CB Bailey


The problem in a DVCS (as in "Decentralized") is the notion of "convention" which can be more important than for a classical VCS.

Since every user will clone the repository, they might have some script already in place which will parse for a "master" branch (like this build.pl perl script)

Even though you can name or organize your branches with whatever name you want in Subversion (you are not required to have a "trunk" for instance), it might be wise, if you publish your repository, to respect at least this convention.

If this is purely internal development (with internal replication for backup purposes for instance), you can name it whatever you want.

like image 32
VonC Avatar answered Sep 24 '22 03:09

VonC