migrate from SVN to GIT

3 May

a short cheat sheet of commands I used several times to migrate SVN-repositories to GIT

  • preparation

    sudo aptitude install subversion git-svn
    svn co https://my.server.private/repos/my_repo
    cd my_repo
    svn log q | grep -v ‘^-*$’ | cut -d ‘|’ -f 2 | sort | uniq > ../my_repo_authors.txt
    cd ..
    vim my_repo_authors.txt
    1. go ahead and edit the authors file
  • git-svn clone the subversion repository
  • use “—no-metadata” only if you don’t want the git-svn-id tags in the commit-messages
    git svn clone —no-metadata —stdlayout \ —authors-file=my_repo_authors.txt \ https://my.server.private/repos/my_repo \ my_repo.git-svn

  • inspect

    cd my_repo.git-svn
    gitk —all
    git branch -a
  • cleanup

    git clone http://github.com/nothingmuch/git-svn-abandon.git
  • check which of the scripts are required in your case:
    view git-svn-abandon/git-svn-abandon-fix-refs
    view git-svn-abandon/git-svn-abandon-msg-filter
    view git-svn-abandon/git-svn-abandon-cleanup
  • FIXME: explain these:
    1. git reflog expire —all —expire=now
    2. git gc —aggressive
    3. git prune
    4. git fsck —full
      git config —remove-section svn
      git config —remove-section svn-remote.svn
      ls .git/svn .git/logs/refs/remotes/
      ls .git/refs/remotes/
      find .git | grep svn
      rm -rf .git/svn/

    5. add remote, push

      git remote add origin git-host:my_repo.git
      git remote -v
      git push —all —verbose
      git push —tags —verbose