Skip to content

Instantly share code, notes, and snippets.

@esutton
Last active April 27, 2022 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esutton/27aebf2ed871f4dc0f73df84f27f89ea to your computer and use it in GitHub Desktop.
Save esutton/27aebf2ed871f4dc0f73df84f27f89ea to your computer and use it in GitHub Desktop.
SVN import to Git

Import SVN commit history from SVN to git

svn-repo=url/path/to/svn/repo
dest-repo-name=my-repo

Create authors.txt file for importing change history

svn checkout ${svn-repo} working-folder
cd working-folder
svn log --xml --quiet | grep author | sort -u | \\n  perl -pe 's/.*>(.*?)<.*/$1 = /' > authors.txt

Edit each line of authors.txt file to format of:

johndoe = John Doe <johndoes@mycompany.com>

Add SVN commit history to git

  • git svn clone can take a long time depending on repo and network speed, perhaps 60 minutes or more.
  • Examine your SVN repo trunk, branches, tags naming conventions, and define runk, branches, tags arguments as needed
    • In the example below, the naming convention used inconsistent upper/lower case
git svn clone --trunk=/Trunk --branches=/branches --tags=/Tags --authors-file=authors.txt ${svn-repo} ${dest-repo-name}

Push to remote

git-repo=path/to/remote/git/repo
git remote add origin ${git-repo}
git push -u origin --all
git push --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment