I read the Git manual, FAQ, Git - SVN crash course, etc. and they all explain this and that, but nowhere can you find a simple instruction like:
SVN repository in: svn://myserver/path/to/svn/repos
Git repository in: git://myserver/path/to/git/repos
git-do-the-magic-svn-import-with-history \
svn://myserver/path/to/svn/repos \
git://myserver/path/to/git/repos
I don't expect it to be that simple, and I don't expect it to be a single command. But I do expect it not to try to explain anything - just to say what steps to take given this example.
Here is a simple shell script with no dependencies that will convert one or more SVN repositories to git and push them to GitHub.
https://gist.github.com/NathanSweet/7327535
In about 30 lines of script it: clones using git SVN, creates a .gitignore file from SVN::ignore properties, pushes into a bare git repository, renames SVN trunk to master, converts SVN tags to git tags, and pushes it to GitHub while preserving the tags.
I went thru a lot of pain to move a dozen SVN repositories from Google Code to GitHub. It didn't help that I used Windows. Ruby was all kinds of broken on my old Debian box and getting it working on Windows was a joke. Other solutions failed to work with Cygwin paths. Even once I got something working, I couldn't figure out how to get the tags to show up on GitHub (the secret is --follow-tags).
In the end I cobbled together two short and simple scripts, linked above, and it works great. The solution does not need to be any more complicated than that!
Several answers here refer to https://github.com/nirvdrum/svn2git, but for large repositories this can be slow. I had a try using https://github.com/svn-all-fast-export/svn2git instead which is a tool with exactly the same name but was used to migrate KDE from SVN to Git.
Slightly more work to set it up but when done the conversion itself for me took minutes where the other script spent hours.
Converting svn submodule/folder 'MyModule' into git with history without tags nor branches.
To retain svn ignore list use the above comments after step 1
I suggest getting comfortable with Git before trying to use git-svn constantly, i.e. keeping SVN as the centralized repo and using Git locally.
However, for a simple migration with all the history, here are the few simple steps:
Initialize the local repo:
Mark how far back you want to start importing revisions:
(or just "git svn fetch" for all revs)
Actually fetch everything since then:
You can check the result of the import with Gitk. I'm not sure if this works on Windows, it works on OSX and Linux:
When you've got your SVN repo cloned locally, you may want to push it to a centralized Git repo for easier collaboration.
First create your empty remote repo (maybe on GitHub?):
Then, optionally sync your main branch so the pull operation will automatically merge the remote master with your local master, when both contain new stuff:
After that, you may be interested in trying out my very own
git_remote_branch
tool, which helps dealing with remote branches:First explanatory post: "Git remote branches"
Follow-up for the most recent version: "Time to git collaborating with git_remote_branch"
I've posted an step by step guide (here) to convert svn in to git including converting svn tags in to git tags and svn branches in to git branches.
Short version:
1) clone svn from an specific revision number. (the revision number must be the oldest you want to migrate)
2) fetch svn data. This step it's the one it takes most time.
repeat git svn fetch until finishes without error
3) get master branch updated
4) Create local branches from svn branches by copying references
5) convert svn tags into git tags
6) Put a repository at a better place like github
If you want more details, read my post or ask me.
I used the svn2git script and works like a charm.