Skip to content

Instantly share code, notes, and snippets.

@linkarys
Last active December 28, 2015 15:29

Revisions

  1. linkarys revised this gist Nov 25, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions svn-to-git
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    # 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>
  2. linkarys revised this gist Nov 22, 2013. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions svn-to-git
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,10 @@ 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
  3. linkarys revised this gist Nov 18, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion svn-to-git
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # get svn user list
    svn log -q svn_repository | grep -e '^r' | awk 'BEGIN {FS = "|" }; {print $2}' | sort | uniq

    # create a users.txt:
    # create file users.txt:
    old_username = new_usename <user_email>

    # svn to git
  4. linkarys revised this gist Nov 18, 2013. 1 changed file with 27 additions and 1 deletion.
    28 changes: 27 additions & 1 deletion svn-to-git
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,32 @@
    # get svn user list
    svn log -q svn_repository | grep -e '^r' | awk 'BEGIN {FS = "|" }; {print $2}' | sort | uniq

    # create a 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
    git svn clone svn_repository --authors-file=users.txt --no-metadata -s 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"'
  5. linkarys renamed this gist Nov 18, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. linkarys created this gist Nov 18, 2013.
    6 changes: 6 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    # get svn user list
    svn log -q svn_repository | grep -e '^r' | awk 'BEGIN {FS = "|" }; {print $2}' | sort | uniq
    # create a 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