Branches are an essential part of contemporary version-control systems, including Git, facilitating branching workflows. Pushing our branches to remotes is a convenient way to collaborate with others and to remotely back up our work on the branch, as well as enabling pull/merge requests on collaborative platforms like GitHub and GitLab. When we are done working with our branch and it has been merged into its intended branch, eg. a default branch like master, we can delete the branch locally and remotely, to avoid cluttering the branch namespaces.

Local branch

Delete a local branch, feature-123-example:

git branch -d feature-123-example

Remote Branch

Delete a remote branch, feature-123-example, from the remote, origin:

Original syntax

git push origin :feature-123-example

Contemporary syntax

git push origin -d feature-123-example