Reasons for not working on the master branch in Git

Other people have made very good cases for not making changes directly in master, and I agree with them. However, always advocating workflows like this sometimes leads people new to git to believe it is needlessly complex, so I wanted to provide a counterpoint.

If you have a one-person or very small team and your development is highly linear, i.e. you rarely work on more than one thing at a time and each feature is usually completed before starting the next, there really is little to no benefit to not work directly out of master. It is very easy to go back and add a branch at any point should the need arise. I highly recommend being aware of the feature branch workflow, but if you feel in your case it's just adding extra steps without buying you anything, I promise I won't tell the git police.


i guess the usual reasoning is, that the master branch should represent the 'stable' history of your code. use branches to experiment with new features, implement them, and when they have matured enough you can merge them back to master.

that way code in master will almost always build without problems, and can be mostly used directly for releases.

let's take git.git (the official git repository) as an example. there are several branches, most noticable:

  • master
  • next
  • pu
  • maint

so, master contains code which is very likely to end up in the next release of git. next contains tested code, which will potentially be merged into the master branch. pu (proposed updates, iirc) contains quite new (and probably) untested code.

pu is considered unstable and will be reset and rebased to junio's liking. next might get reset after a release or during a release cycle, but this is less common. master is set in stone and never changed after it's been pushed and made publicly available.

you see, that changes will get merged from pu to next and from next to master if they are deemed worthy and don't break stuff.

the branch maint is used to make bugfixes which should also apply to older versions of git. maint is usually merged to next and/or master.

you can inspect the branches on http://git.kernel.org/?p=git/git.git;a=summary