Here is a visually appealing guide for migrating from SVN to Git:
Navigate to SVN repo directory:
cd /path/to/svn/repo
Generate authors file:
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > users.txt
This will create a users.txt
file with SVN authors mapped to Git format.
Create new folder for Git repo:
mkdir new-git-repo
cd new-git-repo
Copy users.txt
file there:
cp /path/to/svn/repo/users.txt .
Clone SVN repo into new Git repo folder:
git svn clone --no-metadata -A users.txt https://url/to/svn/repo
This will clone the SVN repo and authors into Git.
Add new empty Git repo as remote:
git remote add mirror https://url/to/new/git/repo.git
Push local Git repo to new Git remote:
git push --set-upstream mirror master
That's it! The SVN repo is now migrated to a new Git remote.
Here is the FAQ in Markdown format:
The key steps are:
- Generate an authors mapping file from SVN
- Create a new Git repo and copy the authors file there
- Clone the SVN repo into Git using the authors file
- Add the new Git repo as a remote
- Push the local Git repo to the new remote
Git stores committer information differently than SVN. The authors file maps SVN authors to Git format so the commit history and authors are preserved.
The command to generate the authors file can fail if the SVN usernames have special characters. Double check the format of the usernames and edit the file manually if needed.
The commit history will lose the authorship information and all commits will be authored by the user performing the migration.
Use SSH rather than HTTPS if you have access. SSH allows pushing without credentials.
Make sure you have permissions to push to the new Git repo. Check that the remote URL and branch name are correct. Use -f if you need to force push.