13 Creating and Switching Branches

Git’s branches enable you to separate experimentation from production-ready code. Git’s convention is to treat the master branch as its main line of code. You can rename it to anything you want, but it’s a good idea to keep with the convention.

You can create a new branch using the git branch command and providing it at least one additional parameter: the name of the branch you want to create. This uses your current location in the repository as the place to create the branch from.

You can also create branches starting at points in the history of the repository. Provide git branch with the name of the new branch you want to create followed by the commit ID or branch or tag name to create a branch ...

Get Pragmatic Guide to Git now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.