Skip to content

Instantly share code, notes, and snippets.

@johnrc
Created April 14, 2017 09:38
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 johnrc/94db756a8e343b9d7102931fadc48640 to your computer and use it in GitHub Desktop.
Save johnrc/94db756a8e343b9d7102931fadc48640 to your computer and use it in GitHub Desktop.
Subversion to Git commands

Below is a list of helpful commands to run a successful migration of Subversion to Git.

svn log --quiet https://svn-server.example.com/repos/my_repo | grep -E "r[0-9]+ \| .+ \|" | cut -d'|' -f2 | sed 's/ //g' | sort | uniq > svnauthors.txt
# convert the `svnauthors.txt` to proper format (name, email) in `authors.txt`
git svn clone --prefix="" --authors-file="authors.txt" -s https://svn-server.example.com/repos/my_repo
java -Dfile.encoding=utf-8 -jar ~/svn-migration-scripts.jar clean-git --force
git remote add origin ssh://git@github.com/my_username/my_repo.git
git push --all
git push --tags

Sometimes the above does not work as expected and you may have to manually add branches (e.g. those not in standard layout).

svn log --quiet https://svn-server.example.com/repos/my_repo | grep -E "r[0-9]+ \| .+ \|" | cut -d'|' -f2 | sed 's/ //g' | sort | uniq > svnauthors.txt
# convert the `svnauthors.txt` to proper format (name, email) in `authors.txt`
git svn init --prefix="" --authors-file="authors.txt" --trunk=trunk --tags=tags https://svn-server.example.com/repos/my_repo
git config --add svn.authorsfile /path/to/authors.txt
git config --add svn-remote.svn.fetch path/to/branches:refs/remotes/only-branch
java -Dfile.encoding=utf-8 -jar ~/svn-migration-scripts.jar clean-git --no-delete --force
git remote add origin ssh://git@github.com/my_username/my_repo.git
git push --all
git push --tags

The command above git config --add came from this guide.

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