Last active
September 30, 2019 07:19
-
-
Save danielwhite/d094e0d8ab0907f681dfc6dcd34f6895 to your computer and use it in GitHub Desktop.
Git Tools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
# | |
# Tidies up the remote and local references of a Git repository. | |
# | |
# By default, it assumes that origin/master is the mainline branch. | |
# | |
GIT_UPSTREAM_REMOTE=${GIT_UPSTREAM_REMOTE:-origin} | |
GIT_UPSTREAM_HEAD=${GIT_UPSTREAM_HEAD:-master} | |
git remote update -p | |
merge_ref="${GIT_UPSTREAM_REMOTE}/${GIT_UPSTREAM_HEAD}" | |
git branch --format '%(refname:short)' --merged ${merge_ref} \ | |
| xargs git branch -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment