有没有人试过或想出如何将一个好的回购导入github?我已经使用github了,想看看是否有办法从一个我想跟随github的gitorub回购。
答案 0 :(得分:25)
这与在Github上创建存储库的常规方法有什么不同?
Github一开始并不关心存储库的来源,它只接受你推送它的任何内容。
答案 1 :(得分:7)
在GitHub上创建新存储库后,该网站立即为您提供3个优雅的个性化指令集。 3种不同的选择是:
如果我的用户名为 user1 且新回购邮件名为 project1 ,则可以这么说:
cd existing_git_repo
git remote add origin git@github.com:user1/project1.git
git push -u origin master
答案 2 :(得分:6)
已经给出的答案只会导入master - 如果要导入整个仓库,包括所有分支,标签等,则需要执行以下操作:
使用--bare标志克隆gitorious repo - 这会保留所有分支/标签,但不会创建工作副本:
$ git clone --bare git://gitorious.org/USER/REPO.git
将目录更改为本地仓库:
$ cd therepo.git
使用--mirror标志将repo推送到github - 这将复制所有分支,标签,历史记录等。:
$ git push --mirror git@github.com:USER/REPO.git
删除本地副本 - 您不再需要它了,它对任何东西都没用多少
$ cd .. && rm -rf therepo.git
完成后,您可以使用上面给出的git remote rm/add
命令切换任何本地回购。
答案 3 :(得分:2)
之前的答案是正确的,但这里是一步一步的过程,包括将本地副本与Gitorious脱钩的缺失步骤;如果没有它,当您尝试将Github添加为新原点时,您将收到错误fatal: remote origin already exists
。
命令:
git clone git://gitorious.org/USER/REPO.git
cd REPO
git remote rm origin
git remote add origin https://github.com/USER/REPO.git
git push --mirror https://github.com/USER/REPO.git
您显然需要替换USER和REPO,并且在创建Github存储库后,在步骤1之后为您提供最后两个命令。