看了@王振威的 “如何导入外部Git仓库到中国源代码托管平台(Git@OSC)”一文, 感受操做比较麻烦。 在此把本身平台导入Github的方法写下来,以供参考。git
在这里以http://github.com/puras/moobo.git为例。github
一、在git@osc上建立一个仓库,最好是同github同名的,在这里叫moobo, 一样,不要勾选使用Readme初始化项目,不要选择项目的受权协议和.gitignore 文件 生成一个空的项目fetch
二、从github上克隆源码: git clone http://github.com/puras/moobo.giturl
三、进入moobo/.git目录,打开config文件,初始内容以下:.net
[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.gitcode
最终内容为:orm
[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
保存文件rem
四、回到moobo目录,执行push命令,即可把代码更新到git@osc上了。 注意,第一次提交须要加参数,命令以下:get
git push -u origin master
注:此时代码能够提交到Github和git@osc,若是不想两个都提交,去掉config中的url一行即可源码