将GIT仓库从Github导入到Git@OSC

看了@王振威的 “如何导入外部Git仓库到中国源代码托管平台(Git@OSC)”一文, 感觉操作比较麻烦。 在此把自己平台导入Github的方法写下来,以供参考。

在这里以http://github.com/puras/moobo.git为例。

1、在git@osc上创建一个仓库,最好是同github同名的,在这里叫moobo, 同样,不要勾选使用Readme初始化项目,不要选择项目的授权协议和.gitignore 文件 生成一个空的项目

2、从github上克隆源码: git clone http://github.com/puras/moobo.git

3、进入moobo/.git目录,打开config文件,初始内容如下:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = http://github.com/puras/moobo.git
[branch "master"]
        remote = origin
        merge = refs/heads/master

在[remote "origin"]下增加一行,内容为: url = http://git.oschina.net/puras/moobo.git

最终内容为:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = http://github.com/puras/moobo.git
        url = http://git.oschina.net/puras/moobo.git
[branch "master"]
        remote = origin
        merge = refs/heads/master

保存文件

4、回到moobo目录,执行push命令,便可把代码更新到git@osc上了。 注意,第一次提交需要加参数,命令如下:

git push -u origin master

注:此时代码可以提交到Github和git@osc,如果不想两个都提交,去掉config中的url一行便可

转载于:https://my.oschina.net/puras/blog/177705

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值