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 trialJaime Sandoval
7,083 PointsWhy use git checkout for the new feature branch when the git branch -b new_feature automatically switches it?
“git branch -b new_feature” should place him in the new_feature branch automatically. So why, after creating the branch with said command, is he in the master branch when he runs “git branch”to view the new_feature branch? He should be in it already.
1 Answer
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,638 PointsThe git checkoutcommand lets you navigate between the branches created by git branch.
While
git branchcommand can be used to create a new branch.
The
git branch` command's primary functions are to create, list, rename and delete branches. To operate further on the resulting branches the command is commonly used with other commands like git checkout.
Andrew Phythian
19,747 PointsAndrew Phythian
19,747 PointsI had a similar question to the OP regarding this part of the teachers notes :
In other words, using git branch -b to create a new branch versus just using git branch is purely for convenience, in that you can execute a single command to be checked out on the new branch rather than any fundamental difference between the two commands.