如何導入外部Git倉庫到中國源代碼託管平臺(Git@OSC即碼雲)
(原文地址:https://www.oschina.net/question/82993_133520)
有如下解決方案:
方案1:
- 從原始地址clone一份bare倉庫
git clone --bare https://github.com/bartaz/impress.js.git (例子)
- 在Git@OSC上創建一個項目(http://git.oschina.net/projects/new),這裏注意,不要勾選使用Readme初始化項目,不要選擇項目的授權協議和.gitignore 文件,因爲這些會導致項目有第一個提交。
- 記下新建項目後的地址,推薦使用http或者ssh方式皆可,大項目推薦ssh方式。
cd impress.js.git
git push --mirror [email protected]:username/impress-js.git
- 此命令執行完成後即完成導入,刪除 impress.js.git 文件夾即可。
方案2:
此方案,手頭已經有了項目的完成倉庫,則無需再從第三方代碼託管平臺上clone下來。
- 到Git@OSC上創建項目,同樣不要選擇以上所說的三項。
- 命令行進入項目目錄,git status 確保項目狀態爲:
nothing to commit, working directory clean
如果狀態不是這樣,則需要通過提交、暫存等操作,使項目當前狀態爲clean。
- 添加Git@OSC的remote
git remote add git-osc [email protected]:username/translate4j.git
- 推送所有分支和tags
git push git-osc --all
git push git-osc --tags
- 以上兩條命令執行完畢,即完成導入。
方案3:
此方案針對導入已有的SVN倉庫
- 同上,先新建項目,不要選擇以上所說的三項
- 使用git-svn工具clone svn倉庫,git-svn 已經是Git的默認組建,如果你安裝的是較新版本的Git客戶端的話,則不需要再單獨下載這個組件
git svn clone http://translate4j.googlecode.com/svn/trunk/ translate4j
- 同樣,進入項目目錄,添加remote
git remote add git-osc [email protected]:username/impress.js.git
- 同樣,推送所有分支和標籤
git push git-osc --all
git push git-osc --tags
- 以上兩條命令執行完畢,即推送完成