In Git, you create a branch, do the work, merge it, and then naturally delete the feature branch. If you use something like GitHub pull requests, removing the remote branch is easy enough with the Delete Branch button after merge. But if you merge locally, you have to clean up both the local branch and the one on the remote. Deleting the local branch is easy. The problem is that I can never remember the command for deleting the remote branch.

The commands look like this:

git branch -D branch-name  # delete local branch
git push origin :branch-name # delete remote branch

Because I kept forgetting the remote-deletion command and looking it up every time, I decided I should just make an alias. While I was at it, I wanted a one-shot command that removed both local and remote together. I needed the branch name as an argument, but Git aliases do not support arguments cleanly. I searched around for a more elegant solution and did not find one I liked, so I ended up with this:

[alias]
  dd = "!f() {  git branch -D $1 && git push origin :$1; }; f"