mirror of
https://github.com/danbee/dotfiles-local
synced 2025-03-04 08:49:07 +00:00
Add git-sweep (stolen from Derek Prior)
This commit is contained in:
parent
9f20fa1e7c
commit
a79417e919
30
bin/git-sweep
Executable file
30
bin/git-sweep
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
git checkout master
|
||||||
|
git fetch
|
||||||
|
git remote prune origin
|
||||||
|
git branch --merged master | grep -v 'master$' | xargs git branch -d
|
||||||
|
|
||||||
|
REMOVABLE=$(git branch -r --merged master \
|
||||||
|
| sed 's/ *origin\///' \
|
||||||
|
| grep -v 'master$' \
|
||||||
|
| grep -v 'production$' \
|
||||||
|
| grep -v 'staging$' \
|
||||||
|
| grep -v '^release' \
|
||||||
|
| grep -v 'next$'
|
||||||
|
)
|
||||||
|
|
||||||
|
if [[ -z "$REMOVABLE" ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "The following remote branches are fully merged and will be removed:"
|
||||||
|
for branch in $REMOVABLE; do
|
||||||
|
echo "$branch"
|
||||||
|
done
|
||||||
|
|
||||||
|
read -p "Continue (y/n)? " -n 1 -r
|
||||||
|
echo
|
||||||
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
|
echo "$REMOVABLE" | xargs git push origin --delete
|
||||||
|
fi
|
||||||
Loading…
Reference in New Issue
Block a user