Last active
December 27, 2021 21:47
-
-
Save JeffBelback/55cd20c8e721ef7fd1f2e6e9f12bff6d to your computer and use it in GitHub Desktop.
Git helper functions
This file contains hidden or 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 | |
# Deletes branches that have been removed on origin | |
function no_remote() { | |
if git rev-parse --git-dir >/dev/null 2>&1; then | |
git fetch --prune | |
echo "Branches with no remote:" | |
git branch -vv | cut -c 3- | awk '$3 !~/\[/ { printf " %s\n", $1 }' | |
echo -e "\nDeleting branches with deleted remote:" | |
del=$(git branch -vv | awk '$4 ~/gone\]/ { printf "git branch -D %s && ", $1 }') | |
del="$del echo \"Complete\"" | |
bash -c "$del" | |
else | |
echo "Not a git repository" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment