Git basics

Delete a branch

Remove a finished branch from your machine and from GitHub.

Fill these in once
  1. Switch off the branch first
    Terminal
    git switch main
  2. Delete it on your machine
    Terminal
    git branch -d fix-login-button

    Git refuses if it isn't merged yet. Use -D instead of -d to delete it anyway.

  3. Delete it from GitHub
    Terminal
    git push origin --delete fix-login-button

Check it worked

  1. See the branches that are left
    Terminal
    git branch -a
  1. Switch off the branch first
    Terminal · Ubuntu / Debian
    git switch main
  2. Delete it on your machine
    Terminal · Ubuntu / Debian
    git branch -d fix-login-button

    Git refuses if it isn't merged yet. Use -D instead of -d to delete it anyway.

  3. Delete it from GitHub
    Terminal · Ubuntu / Debian
    git push origin --delete fix-login-button

Check it worked

  1. See the branches that are left
    Terminal · Ubuntu / Debian
    git branch -a
  1. Switch off the branch first
    PowerShell
    git switch main
  2. Delete it on your machine
    PowerShell
    git branch -d fix-login-button

    Git refuses if it isn't merged yet. Use -D instead of -d to delete it anyway.

  3. Delete it from GitHub
    PowerShell
    git push origin --delete fix-login-button

Check it worked

  1. See the branches that are left
    PowerShell
    git branch -a