There's a lot of information describing how to migrate from Subversion to GIT, but very little which describes the process under Windows. In particular most references assume that you can reference the Subversion repository using
file:// which is currently not the case. You need to access the Subversion repository using the
Assuming you already have GIT installed:
- Create a file
users.txt, which is a mapping of your Subversion user to GIT users. You'll have one line per user that has committed to the Subversion repository. You can have a single file stored centrally somewhere if you are migrating a number of repositories.
SVN_USERNAME = GIT_USERNAME [user_email_address]
- The key to the entire migration under Windows is that you need to have the
svnserve.exeSubversion service running. Depending on your Subversion setup you may or may not already have this running. If you're using TortoiseSVN, right click on the woring copy, and select "TortoiseSVN->Relocate". Or, start the Repository Browser by pasting the url into a browser,
- Create a directory for the GIT repository.
- Run the GIT Subversion migration utility. The example below transfers all Subversion tags, and all commits made to the "trunk" directory, no data is moved from other Subversion directories:
git svn clone "[svn-repository-url]" -A [path-to]users.txt -t tags -T trunk --no-metadata "[path-to-git-directory]"
- [svn-repository-url]: Is the url to the SVN repository, for example "svn://localhost/Choice". If you use TortoiseSVN, you can find this url by right clicking your working directory, and selecting "TortoiseSVN->Relocate".
- -A [path-to-git-directory]: The full path to the directory you created for the GIT repository, for example "D:\Projects\pmwiki\Choice".
- -t tags: The name of the Subversion tags directory.
- -T trunk: The name of the Subversion trunk directory.
- --no-metadata: Omits the metadata used by Git to synchronize repository with SVN. By default git-svn adds a bunch of extra information to commit messages, which is not particularly useful.
- [path-to]users.txt: Is the path to the
users.txtfile you created, for example "D:\Projects\users.txt".
- The migration might take quite a while, but you should see status messages flying by. Next is to do some clean-up, since git seems to convert tags into branches. Change to the directory you created your git repository in, and run the following:
git reset --hard copy .git\refs\remotes\tags\. .git\refs\tags\ del /q .git\refs\remotes\tags\ copy .git\refs\remotes\ .git\refs\heads\ del /q .git\refs\remotes rd .git\refs\remotes\tags
If things worked you should have a hidden
.git directory in the GIT directory you created. If you're using TortoiseGIT, right-click on your project directory, and select "TortoiseGIT->Show Log".
The last step I usually do is to push the GIT repository to GitHub. Create a new repository on GitHub, and then:
- Create an alias to the remote repository:
git remote add [alias-to-github] [url-to-git-hub-repository]
- [alias-to-github]: A name you'll use to refer to the remote repository, for example "github", or "origin".
- [url-to-git-hub-repository]: The URL to your remote repository, usually shown after you create the repository in GitHub, for example "firstname.lastname@example.org:Nepherim/Choice.git".
- Tag your current local repository with the latest version number, and then push the most recent version over to GitHub:
git tag [version-number] git push github [version-number]:refs/heads/master --tags --force