** originally posted here: nirvdrum/svn2git#295 ** ** Note this guide is old, but svn2git still hasn't been updated. **
Hello my fellow SVN refugees. We are bailing from Cloudforge as they are shutting down their SVN services. Here's how I got svn2git to work on my Mac locally. (Mojave 10.14.6). This should help with (#292) and (#283)
- We're lucky to have a standard svn layout. I'm afraid I can't help with non-standard.
- Using bash and iterm2.
- Make sure your password doesn't have any dollar signs or other special bash characters like a space or backslash. If you have a dollar sign in your password you are going to have a bad time. I don't know how to get around it, its easier to just change your password.
- I used rvm to install ruby 2.4.0
rvm install "ruby-2.4.0"
rvm use 2.4.0 --create
gem install svn2git
- start from inside a blank folder
- My final command looked something like this. The
--authors
parameter is optional, but probably desired. See "Extra: generate an authors file" below for how to do this.
svn2git https://svn.example.com/path/to/repo --username myusername --authors ../your_authors_file.txt
- Here's the weird part. When prompted for password I had to paste my password in, hit enter, paste again then hit enter. Then the prompt comes up AGAIN and I have to repeat: paste password, hit enter, paste password hit enter. Then it started working. Not sure which part of that is actually correct but it worked.
And for the sake of completion here are some other details.
-
If all goes well, and you did run the command in an EMPTY folder, you should have nothing uncommitted remaining in your folder.
-
You will need an empty repository on your new git host.
-
It is traditional and/or mandatory for some hosted git services to have a README.md so create that and commit.
-
Final steps after conversion:
- add your new git origin from the local folder
git remote add origin [email protected]:<project>.git
- push all branches of your newly converted git repo
git push --all origin
- push all tags tags
git push --tags origin
- add your new git origin from the local folder
source https://docs.gitlab.com/ee/user/project/import/svn.html#cut-over-migration-with-svn2git
- The authors file maps your svn usernames to a git username and email. Otherwise the old commits wont match to the usernames. This is probably a big deal.
- You would do this BEFORE running svn2git
- You will need a checked out copy of the svn repo to generate the authors file, even though you will need an empty folder to do the svn2git conversion (AFAIK).
- Go into the svn folder locally, run:
svn log --quiet | grep -E "r[0-9]+ \| .+ \|" | cut -d'|' -f2 | sed 's/ //g' | sort | uniq
It will output a list of usernames. It will take a while. Take the output and construct an authors.txt file in this format:
janedoe = Jane Doe <[email protected]>
johndoe = John Doe <[email protected]>
Map ALL the users that come out or it will fail. Use this file in the --authors
parameter.