Skip to content

Instantly share code, notes, and snippets.

@anandjagadeesh
Last active September 13, 2020 12:50
Show Gist options
  • Save anandjagadeesh/0a47d7b29ae874e04889c1ac8181c731 to your computer and use it in GitHub Desktop.
Save anandjagadeesh/0a47d7b29ae874e04889c1ac8181c731 to your computer and use it in GitHub Desktop.

To delete any branch, you shouldn't be on that branch, so switch to another branch before giving the commands

To delete any branch run,

git branch --delete <branch_name>
or
git branch -d <branch_name>

But this fails if the branch hasn't been merged, so to force delete, if required, run,

git branch --delete --force <branch_name>
or
git branch -D <branch_name>

To delete the remote branch, you need to run,

git push origin --delete <branch_name>
or
git push origin :<branch_name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment