Patricio Treviño

Patricio Treviño

Husband . Father . Developer

Delete a local git branch using the terminal

Syntax

git branch <[-D | -d | --delete]> <branch>
view raw syntax.text hosted with ❤ by GitHub

Option Description
option The delete option to be used.
branch The local branch to be deleted.

Note: valid options are:
-D, forces the deletion of the local branch even if there are pending merges.
-d, is a synonym of --delete.
--delete, deletes the local branch with no pending merges.

Example

# deletes local branch "my-branch"
git branch --delete my-branch
# same as above
git branch -d my-branch
# forces the deletion of the local branch "my-branch"
git branch -D my-branch
view raw example.sh hosted with ❤ by GitHub

References

git-branch