If the master is default branch of git repository, why should we create another branch? What is the benefits of creating new branch?
-
http://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging – PM 77-1 May 07 '15 at 04:08
-
1There's only one answer for this question and that's 42. – Noufal Ibrahim May 07 '15 at 04:11
2 Answers
Your question is really a general version control question, and would be equally valid if you were asking about Subversion, Perforce, or any other VCS.
Typically you would want to create a new branch in Git when you want to build a new feature based on the master
branch, without doing the actual work in master
. By using a separate branch for your feature, you can do all your development and testing in a separate place, leaving your stable master
branch alone. This would allow other developers to continue working directly in master
or to allow them to create their own feature branches.
Once you have completed the feature and it has been tested, you can bring this branch back into master
by using git merge
or by doing a git rebase
followed by a fast-forward.

- 502,043
- 27
- 286
- 360
master represents a stable version of your app, so you won't check in incomplete, pending-review code into master.
Check this post: Git branch strategy for small dev team