Git迁移 从SVN到Git

本文详细介绍如何从Subversion (SVN) 迁移到Git版本控制系统。包括在Stash或GitHub创建新的Git仓库并获取其URL,转换SVN目录结构为Git格式,设置远程仓库同步及推送本地代码到远程分支等步骤。

Migrating from SVN to Git 

首先我们需要在Stach或者GitHub上新建一个Repository, 拿到它的URL。 接下来参照如下步骤 :

At first we should create a new git repository at Stash and get the repository URL, and then follow below steps:

1. 切换到本地git工作目录

    change to the git working directory : 

    $cd c:/git

 

2. 将svn目录格式转换为git形式, 可选为标准格式或Trunk格式

    --import the contents (svn repository) into the new Git repository: 

    this command transform the trunk, branches, and tags in SVN repostory into a new repository.

    Depending on different structure of SVN layout, we need different parameter for this command.

    [1] $git svn clone [svn repository url] -s

         -s : standard layout, there should be trunk,branches, and tags for SVN repository. 

    [2] $git svn clone [svn repository url] -t Trunk

         -t Trunk :  only for trunk 

         

3. 连接同步本地库和远程库

    $git remote add origin [git repository url]

    this command is used to add a remote which is just a shotcut for the git repository url.

    Now we use the command to add a remote "origin" for our new git repository

   

4. 推送本地代码到远程分支

    $git push origin --all

    this command push all the local repository to bitbucket repository.

 

    If you just need to push specific branch, such as "master" , use this command :

    $git push origin master

 

    After these , Bitbucket repository is now a clone of local repository, we can check the history at the Stash.

转载于:https://www.cnblogs.com/djoel/p/5620245.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值