Delete a git branch from local and remote

Git branch can be deleted easily using following commands

$ git push -d <remote> <branchname> // this will delete remote branch

$ git push <remote>:<branchname> // this will delete remote branch 

Most of the time remote name is origin. For deleting git branch locally you can use following command

$ git branch -d <branch_name> // delete a local branch which has nothing to commit
$ git branch --delete <branch_name> //same as above

$ git branch -D <branch_name> // deletes a branch even if it has uncommitted changes
$ git branch --delete --force <branch_name> // same as above

If you are working in a large team and you don’t want to keep deleted branch locally you can prune your repo by using following command

git fetch --all --prune // this will remove all branches and tags which have been deleted on remote

Hope this helps!!!

A pat on the back !!