git checkout -b <branchname>

Create a new branch and switch to it

This git checkout -b command creates a new branch with the specified name, and then switches to that branch. It is a combination of two individual commands: git branch <branchname> which creates a new branch, and git checkout <branchname> which switches to the new branch.

Potential variations include:

  • git checkout --orphan <branchname>: Creates a new orphan branch without any commit history.
  • git checkout -b <branchname> <commit>: Creates a new branch with the specified name and starting from the specified commit.

Sign in to enable bookmarking, reminders, progress-tracking and more...