Skip to content

Instantly share code, notes, and snippets.

@linkarys
Last active December 28, 2015 15:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linkarys/7521567 to your computer and use it in GitHub Desktop.
Save linkarys/7521567 to your computer and use it in GitHub Desktop.
svn-to-git
# 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"'
@xinju
Copy link

xinju commented Nov 18, 2013

This is really cool!

@linkarys
Copy link
Author

very happy to see that :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment