Branching

Branching

Create a branch and switch to it

$ git switch -c feature/name

Delete a branch (local and remote)

$ git branch -d feature/name                # local (safe — only if merged)
$ git branch -D feature/name                # local (force — even if unmerged)
$ git push origin --delete feature/name     # remote

Rename the current branch

$ git branch -m new-name

See which branches are merged into main

$ git branch --merged main

Safe to delete any branch listed here (except main itself).

On this page