Last active
December 28, 2015 15:29
-
-
Save linkarys/7521567 to your computer and use it in GitHub Desktop.
svn-to-git
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
# get svn user list | |
svn log -q svn_repository | grep -e '^r' | awk 'BEGIN {FS = "|" }; {print $2}' | sort | uniq | |
svn log --xml svn_repository | grep author | sort -u | perl -pe 's/.>(.?)<./$1 = /' | |
# create file users.txt: | |
old_username = new_usename <user_email> | |
# svn to git | |
git svn clone svn_repository --authors-file=users.txt --no-metadata -s git_fold | |
# specify reversion | |
git svn clone svn_repository --authors-file=users.txt --no-metadata -sr 1342:HEAD git_fold | |
# include only trunk and branches | |
git svn clone svn_repository --authors-file=users.txt --no-metadata --trunk=trunk --branches=branches -r 1342:HEAD git_fold | |
# update svn commiter and author | |
git filter-branch --commit-filter ' | |
if [ "$GIT_AUTHOR_NAME" = "old_name" ]; | |
then | |
GIT_AUTHOR_NAME="new_name"; | |
GIT_AUTHOR_EMAIL="user_email"; | |
git commit-tree "$@"; | |
else | |
git commit-tree "$@"; | |
fi | |
if [ "$GIT_COMMITTER_NAME" = "old_name" ]; | |
then | |
GIT_COMMITTER_NAME="new_name"; | |
GIT_COMMITTER_EMAIL="user_email"; | |
git commit-tree "$@"; | |
else | |
git commit-tree "$@"; | |
fi' HEAD | |
# remove git-svn-id | |
git filter-branch --msg-filter 'sed -e "/^git-svn-id:/d"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
very happy to see that :D