Create Branch and Check Branch Status – Git Branch

Creating and Managing Branches with git branch

git branch is a multi-use command. We'll explain the three major use cases on this page.

The git branch command use cases

  1. Create a new branch
  2. Check branch status
  3. Delete an unused existing branch

1. Create a new branch

Creating a new branch is the first action in the branch operation. When running git branch [new branch name], a new branch is created from the original branch where you are located.

However, you are still on the original branch until you switch the current branch to the newly created branch by running the git checkout or git switch commands, which will be explained on the next pages.

Also, one important note here is that a new branch diverges from the latest commit (HEAD) of the parent branch. Unless you rebase it (to be explained later), the diverged point remains the same throughout the entire life cycle of the branch.

Example

If you want to create a new branch named Branch_A, run the command below.

git branch Branch_A