Using git-svn under Windows for migrating SVN repo into Git
I wanted to import SVN repository into Git repository, where SVN repo had uncommon structure (without trunk
/ branches
/ tags
folder). And I wanted to skip all the remote branches stuff, just export entire SVN repository as current master branch in Git repo.
Note, that I used console commands (like git svn
) only to do hard job of migration. Other stuff, that I was able to achieve in TortoiseGit (like pushing to remote) I did manually.
First I cloned SVN repository into temporary Git repository:
git svn clone --no-metadata -A users.txt svn://url/svn/datter/ datter_tym
(file with users list — users.txt
— must be provided without path!)
I used this without --stdlayout
, because I didn’t have standard SVN structure. If your layout differs, become familiar with --tags
, --branches
and --trunk
options (or generally read git svn help
contents).
Then I tried:
cd datter_tym
git svn fetch
But it failed with error:
Can’t open /c/XAMPP/htdocs/C:/XAMPP/htdocs/users.txt No such file or directory.
The solution was to move users.txt
to root folder on my C:\ disk.
git config svn.authorsfile c:users.txt
git svn fetch
If you need to know structure for users-file then this link should help.
Next, I cloned that temporary post-import repo into a clean Git repo:
cd ..
git clone datter_tym datter
rmdir /s datter_tym
cd datter
Then I needed to deal with remote in this new repo:
git remote rm origin
git remote add origin ssh://url/git/datter/
Finally, I have pushed all local changes to new repository:
git push --all --force --progress "origin"
Above was for forcing intial push, with all branches (--all
) and with overwriting existing (--force
).
For normal, everyday use I’m rather using this:
git push --progress "origin" master
As a really last step, I have deleted the users.txt
file.
I used following articles to solve my problem:
- Stack Overflow: How to migrate SVN repository with history to a new Git repository,
- johnclarkemills.com: Migrate from SVN to GIT with history,
- john.albin.net: Converting a Subversion repository to Git,
skipping unrelated parts and porting some commands to Windows.
If anything is not clear enough or if above sources are not enough for you, consider using these ones:
I found them, when googling, but I haven’t used them (so I don’t know their value), as two first were enough.
In addition, if you have TortoiseGit installed on your computer, you can try to open git-svn.html
file from /Git/doc/git/html/
subfolder in directory, where you installed TortoiseGit. It basically containsgit svn
command syntax details, which may be unavailable, if you are using Windows.