git branch <branchname>
Creates a new branch with the specified name.
Creating branches allows you to isolate work on different features or fixes, and this command initializes a new branch pointer at the current commit.
This command takes a single parameter, the branch name (<branchname>), and then creates a new ref under refs/heads/ that points at the current HEAD; if the name already exists you'll get an error and no branch is created.
Common variations include listing all branches with git branch -a, deleting a branch with git branch -d <branchname>, or renaming one via git branch -m <oldname> <newname>; for creating and checking out in one go, you can use git checkout -b <branchname> or git switch -c <branchname>.
Examples:
git branch feature-xyzgit branch hotfix-login-bug
Related commands