FahamLah

Commands

git branch

git branch <name> [<start>] · git branch -d <name>

Risk: Careful

What it does

Makes, renames or deletes a branch. A branch is a sticky note on a commit.

When to use it

To start new work without touching main.

Example

$ git branch feature/login-form

Make a new branch here. You stay where you are.

$ git branch -d feature/login-form

Delete a branch that is already merged. Safe.

$ git branch -D old-idea

Delete it even if it is not merged. Careful!

$ git branch -m new-name

Rename the branch you are on.

$ git branch --merged

Which branches are already merged here?