Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Export/Imports commits from/to a git branch
for i in $(git branch|cut -b 3-|sed -e '/^trunk$/d;/^svnadmin$/d')
do
mkdir -p ../patch/$i
git format-patch -o ../patch/$i origin/trunk..$i
git show $(head -1 ../patch/$i/0001-*|awk '{print $2}')~1|grep git-svn-id > ../patch/$i/rev-svn
done
for i in $(find ../patch -name rev-svn|sed -e 's/^..\/patch\///;s/\/rev-svn$//')
do
rev=$(sed -e 's/.*@\([[:digit:]]*\) .*/\1/' ../patch/$i/rev-svn)
gitrev=$(git svn find-rev r$rev trunk)
git branch $i $gitrev
git branch --set-upstream-to=trunk $i
git checkout $i git am --committer-date-is-author-date ../patch/$i/*.patch
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment