Skip to content

Instantly share code, notes, and snippets.

Created March 21, 2013 23:49
Show Gist options
  • Save anonymous/5217870 to your computer and use it in GitHub Desktop.
Save anonymous/5217870 to your computer and use it in GitHub Desktop.
Script to remove orphaned branches from a git-svn repo
$REPO=`git svn info | grep "Repository Root: " | sed -e 's/Repository Root: //'`
git branch -r | sed 's|^[[:space:]]*||' | grep -v '^tags/' > git-branch-list
svn ls $REPO/branches | sed 's|^[[:space:]]*||' | sed 's|/$||' > svn-branch-list
diff -u git-branch-list svn-branch-list | grep '^-' | sed 's|^-||' | grep -v '^trunk$' | grep -v '^--' > old-branch-list
for i in `cat old-branch-list`; do git branch -d -r "$i"; rm -rf .git/svn/refs/remotes/"$i"; done
rm -v old-branch-list svn-branch-list git-branch-list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment