Skip to content

Instantly share code, notes, and snippets.

@skeep
Last active December 28, 2018 11:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save skeep/8ffd7e590ddc3f88a43456d69b5d95b1 to your computer and use it in GitHub Desktop.
Save skeep/8ffd7e590ddc3f88a43456d69b5d95b1 to your computer and use it in GitHub Desktop.
#!/bin/bash
# pick only branch name
awk -F"\torigin/" '{print $NF}' branches.txt > branches_trancated.txt
# Make it a space seperated single line
awk '$1=$1' ORS=' ' branches_trancated.txt > branches_space.txt
# cleanup
rm -f branches.txt branches_trancated.txt
branches=$(<branches_space.txt)
echo ${branches_space}
#delete remote branches as well as prune from local
for branch in $branches
do
git push origin --delete $branch
done
git remote prune origin
rm branches_space.txt;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment