Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Git Basics Branches Branching Out

What is branch in git? and what are its uses?

a

2 Answers

Basically, you have your master branch and you don't want to mess anything up on that branch. However, you need to implement a new feature that works with the codebase on the master branch. A branch will allow to make a "copy" while not affecting the original branch (master in this case).

So, to get around this problem you can a branch (We'll call it 'new_feature') that is a copy of the master branch and add your new feature code the the new_feature branch. Once you have finished implementing the new feature you merge the new_feature branch with master and BOOM, done.

I will include a link to the gitflow workflow. This really helped me understand branching and why you should use it.

Nicholas Arcuri
Nicholas Arcuri
11,311 Points

Think of it like a tree.. The master is the trunk, of which you can branch off from. You start a new branch off of the original master so that you can make changes to the project without affecting the original master branch. Whoever else is working on the project can continue with the master branch as well. Then, when you finish your changes you can merge back with the master branch and your changes will be present, along with whatever else was changed in the meantime.