Last active
August 29, 2016 15:41
-
-
Save mrzechonek/7150855 to your computer and use it in GitHub Desktop.
svn2git.sh
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
#!/bin/bash | |
if [ ! -d "$1" ]; then | |
echo "Please provide a single command to the repository" | |
echo "Subversion upstream should be cloned with:" | |
echo " git svn clone --prefix=svn/ -s <url>" | |
echo "Git upstream should be added with:" | |
echo " git remote add origin <url>" | |
exit 1 | |
fi | |
pushd $1 | |
# pull changes from subversion | |
git svn rebase --fetch-all | |
# convert svn tags into git tags | |
git branch -r | sed -rne 's, *svn/tags/([^@]+)$,\1,p' | while read tag; do | |
git tag $tag svn/tags/$tag^ | |
done | |
# convert svn branches into git branches | |
git branch -r | grep -v 'svn/\(tags\|trunk\)' | sed -rne 's, *svn/([^@]+)$,\1,p' | while read branch; do | |
git branch --force $branch svn/$branch | |
done | |
# push branches to git | |
git push --all origin | |
# push tags to git | |
git push --tags origin | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment