Skip to content

Git

An empty commit, an empty message, or both:

Terminal window
git commit --allow-empty --message 'Initial commit'
git commit --allow-empty-message --message ''
git commit --allow-empty --allow-empty-message --message ''

Delete local branches except the current one

Section titled “Delete local branches except the current one”
Terminal window
git for-each-ref --format='%(refname:short)' refs/heads/ \
| grep -vxF "$(git branch --show-current)" \
| xargs -r git branch -d

-d deletes only merged branches; -D forces deletion and loses unmerged commits.