Created
July 3, 2014 12:56
-
-
Save jamesmyatt/4bbde4fed7a878836960 to your computer and use it in GitHub Desktop.
Script to remove obsolete SVN branches from git-svn repository
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
svn_repos=`git config --get-all svn-remote.svn.url` | |
svn_prefix=svn/ | |
git branch -r | sed 's|^[[:space:]]*||' | grep "^${svn_prefix}" | grep -v "^${svn_prefix}tags/" > git-branch-list | |
svn ls $svn_repos/branches | sed 's|^[[:space:]]*||' | sed 's|/$||' | sed "s|^|${svn_prefix}|" > svn-branch-list | |
echo "${svn_prefix}trunk" >> svn-branch-list | |
diff -u git-branch-list svn-branch-list | grep '^-' | grep -v '^--' | sed 's|^-||' > old-branch-list | |
echo 'Obsolete branches:' | |
cat old-branch-list | |
read -n1 -r -p "Press any key to continue..." key; | |
for i in `cat old-branch-list`; do git branch -d -r "$i"; rm -rf .git/svn/refs/remotes/"$i"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment