Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert svn repository to git on Windows

Tags:

git

windows

svn

We have remote svn repository and we want it to convert to git. Could you please tell me how is it possible to do it on Windows? Thank.

like image 318
Oleg Avatar asked Jan 06 '12 16:01

Oleg


1 Answers

Install application on Windows:

  • Git for Windows.
  • TortoiseGit

Find out the svn repository URL and copy it

Something like this:
enter image description here

Invoke TortoiseGit Clone dialog

Right click on destination folder, e.g. D:\SVN\ToGit, and Click Git Clone...
enter image description here

Check the From SVN repository checkbox

enter image description here

If you copied the URL first, then invoke the clone dialog, TortoiseGit will get the copied URL from clipboard and paste it into the URL text field for you. So, you don't paste it by yourself. Just have look at it to see if it's correct.

And if you right click on destination folder, TortoiseGit also fill the Directory text field for you. Also, take a look to see if it's what you want.

So, just check the From SVN repository checkbox.

And if the svn repository has the standard layout, say trunk, tags, branches, you don't need to do anything further.

Click the OK button to go

Then, starting to clone a svn repository to git repository.
Something like this:

enter image description here

As you can see, TortoiseGit just properly uses Git for Windows command git svn clone to clone it.

git.exe svn clone "svn://svn.code.sf.net/p/tortoisesvn/code/" "D:\SVN\ToGit\tsvn" -T trunk -b branches -t 

So, basically, you can go Git Bash/CMD and re-use that command line, and also get the same result.

NOTE: If you can see the r1, r2, r3..., you can stop the cloning anytime, and resume it later by using the same command line.


Clone a local svn repository

With TortoiseGit 2.4.4+

Just copy the svn local path into URL of Clone dialog. See:
enter image description here
Again, Check the From SVN repository checkbox

Cloning:
enter image description here

TortoiseGit 2.4.4+ will use file:/// protocol to clone a local svn repository.


After you get a git repository, you can commit there. And push the commit back to origin svn repository by using TortoiseGit ->SVN DCommit..., something like svn commit.

enter image description here

enter image description here

As you can see, the command is git svn dcommit.

And if the origin svn repository has some new commit(s) need to update, you can use TortoiseGit ->SVN Rebase to fetch the svn commit and then merge/rebase on the latest commit. Something like svn update.

enter image description here

It uses git svn fetch then uses git rebase to merge/rebase the fetched changes.

enter image description here

For command line, you could just use git svn rebase.


Read Pro Git v2 - Chapter 9 for more information and examples.

like image 109
Yue Lin Ho Avatar answered Sep 24 '22 06:09

Yue Lin Ho