Skip to content

Instantly share code, notes, and snippets.

@jgusta
Created October 10, 2022 02:05
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 jgusta/9cc0650ba12578a7d3391a1e424b10b1 to your computer and use it in GitHub Desktop.
Save jgusta/9cc0650ba12578a7d3391a1e424b10b1 to your computer and use it in GitHub Desktop.
Getting svn2git to work on Mac 8/2020

Getting svn2git to work on Mac 8/2020

** 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.

After conversion

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 xxxx@xxxx.com:<project>.git
    • push all branches of your newly converted git repo git push --all origin
    • push all tags tags git push --tags origin

Extra: generate an authors file

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 <janedoe@example.com>
johndoe = John Doe <johndoe@example.com>

Map ALL the users that come out or it will fail. Use this file in the --authors parameter.

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