Last Updated: February 25, 2016
· klj613

Develop or not to develop in master branch

Some people think the "master" branch is special. But why?

I can do anything with my local master branch... git branch -D master.

I can still do git fetch, git checkout -b feature-x origin/master --no-track

I do NOT need a local master branch

I can do ANYTHING with my local master branch who would know?

If you always have a code review then yes, you will need a new feature branch...

hold on.. but git is decentralized.. if you get bob to review your master changes then ask bob to...

git remote add johndoe git@
git fetch
git diff origin/master...johndoe/master

Then bob will say "ship it!" and then you will...

git push origin master

The only problem is... not many (in my experience) teams use git in a decentralized manner. Instead they have a "main" repository (github).

So majority of the time you would want to create a branch, push to origin and get someone to code review it. Its simple that way.

You could commit on master (experiment) then if you want to make it into a branch git checkout -b feature-y, git push origin feature-y, git checkout master, git reset --hard origin/master


This post is just to open your mind to: origin/master is special, not master.

You don't even need the local master branch: git branch -D master and use origin/master instead.