分享

Migrate from svn to git | GitStack

 思考的轨迹 2012-05-09

Migrate from svn to git

Mon, Apr 2, 2012
Subversion was the most used versioning system until last year. A majority of new projects are now using git and most of the older but active project are now migrating from subversion to git.

This tutorial will show you how to migrate your subversion server (online hosted or using a software like visualsvn server) to a git server (GitStack).

The migration process has 4 steps :
1. Use git to checkout your svn repository
2. Clean your project from unnecessary files
3. Create a new remote git repository on GitStack
4. Push your repository to GitStack

Prerequisites :
-msysgit installed on a client computer
-GitStack installed on a remote computer

1. Use git to checkout your svn repository


We take as our svn repository example “fotoslide” which is a project randomly chosen on google code http://code.google.com/p/fotoslide/

Launch git bash (provided by msysgit)
launch gitbash

Checkout your svn project on your client computer :
$ git svn clone http://fotoslide./svn/ –no-metadata -s fotoslide

Git will download all the repository files and history. It might take a few minutes/hours depending of the size of your svn repository. The ‘–no-metadata’ parameter is used to remove unnecessary svn backward compatibility data (git-svn-id is not imported).



2. Clean your project from unnecessary files


Get into your project directory :
$ cd fotoslide

Convert weird tag branches to real git tags :
$ cp -Rf .git/refs/remotes/tags/* .git/refs/tags/
$ rm -Rf .git/refs/remotes/tags

Convert old svn branches to real git branches :
$ cp -Rf .git/refs/remotes/* .git/refs/heads/
$ rm -Rf .git/refs/remotes

cleanup svn references

3. Create a new remote git repository on GitStack


Launch GitStack on your server and create one user
Create a repository. We will name it fotoslide.
Add a user with read/write access to the repository.

create user gitstack
create repo

4. Push your repository to GitStack


Add the git server as a remote server :
$ git remote add origin http://10.0.2.15/fotoslide.git

Push your code to the new server, including all the tags and branches :
$ git push origin –all

git push

You have successfully migrated your repository from svn to git.

migration svn git complete

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多