Patricio Treviño

Patricio Treviño

Husband . Father . Developer

Delete a local git branch using the terminal

facebook sharing button
twitter sharing button
linkedin sharing button
reddit sharing button
digg sharing button
tumblr sharing button
whatsapp sharing button
email sharing button
print sharing button

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