将现有的git项目导入GitLab?

时间:2013-12-03 19:28:58

标签: git gitlab

我有一个Gitlab安装帐户,我创建了存储库“ffki-startseite”

现在我想将存储库git://freifunk.in-kiel.de/ffki-startseite.git克隆到具有所有提交和分支的存储库中,因此我可以在自己的范围内开始处理它。

如何导入它?

10 个答案:

答案 0 :(得分:134)

通过以下在我的计算机上本地运行的命令,我能够将项目以及所有提交,分支和标记完全导出到gitlab:

  

为了说明我的示例,我将使用https://github.com/raveren/kint作为我要导入gitlab的源存储库。我事先在gitlab中创建了一个名为Kint的空项目(在名称空间raveren下),它告诉我新创建的项目的 http git url http://gitlab.example.com/raveren/kint.git

     

这些命令与操作系统无关。

new 目录中:

git clone --mirror https://github.com/raveren/kint
cd kint.git
git remote add gitlab http://gitlab.example.com/raveren/kint.git
git push gitlab --mirror

现在,如果您有一个本地克隆的存储库,您希望继续使用新的远程数据库,只需在那里运行以下命令:

git remote remove origin
git remote add origin http://gitlab.example.com/raveren/kint.git
git fetch --all

*这假设您没有从origin重命名远程主控,否则,请更改前两行以反映它。

答案 1 :(得分:103)

将新的gitlab远程添加到现有存储库并按下:

git remote add gitlab url-to-gitlab-repo
git push gitlab master

答案 2 :(得分:17)

保持所有标记和分支

只需在existing Git repository

中运行此命令即可
cd existing_repo
git remote add gitlab git@git.hutber.com:hutber/kindred.com.git
git push -u gitlab --all
git push -u gitlab --tags

答案 3 :(得分:12)

以下是Gitlab提供的步骤:

"CallbackPath": "/signin-oidc",

答案 4 :(得分:11)

rake gitlab:import:repos可能是更适合批量导入的方法:

  • 复制repos_path/home/git/repositories/group/repo.git)下的裸存储库。目录名称必须以.git结尾,并且位于组或用户名称空间下。
  • 运行bundle exec rake gitlab:import:repos

所有者将是第一个管理员,如果尚未存在,则会创建一个组。

另请参阅:How to import an existing bare git repository into Gitlab?

答案 5 :(得分:7)

这是一个回到新地点的基本举动。我一直都在使用这个序列。使用 - bare ,将看不到源文件。

打开Git Bash 创建存储库的裸克隆。

git clone --bare https://github.com/exampleuser/old-repository.git

镜像推送到新存储库。

cd old-repository.git

git push --mirror https://github.com/exampleuser/new-repository.git

删除您在步骤1中创建的临时本地存储库。

cd ../
rm -rf old-repository.git

答案 6 :(得分:3)

git clone --mirror git@github.com:username/repo-name.git

git remote add gitlab ssh://git@servername.com/username/repo.git

git push -f --tags gitlab refs/heads/*:refs/heads/*

最好通过ssh执行此操作,https可能无法正常工作

答案 7 :(得分:2)

将项目从GitHub移至GitLab,包括问题,拉取请求Wiki,里程碑,标签,发行说明和评论

有关GitLab文档的详尽说明:

https://docs.gitlab.com/ee/user/project/import/github.html

TL;博士

  • 确保要映射到GitLab用户的任何GitHub用户都具有:

    • 使用GitHub图标登录的GitLab帐户 - 或 -
    • GitLab帐户,其电子邮件地址与GitHub用户的公共电子邮件地址相匹配
  • 在顶部导航栏中,单击+并选择新建项目。

  • 选择“导入项目”选项卡,然后选择“GitHub”。
  • 选择列出GitHub存储库的第一个按钮。您将被重定向到github.com上的页面以授权GitLab应用程序。
  • 点击授权gitlabhq。您将被重定向回GitLab的“导入”页面,并列出所有GitHub存储库。
  • 继续选择要导入的存储库。

但请阅读GitLab Docs page了解详情和摘要!

(它并不多)

答案 8 :(得分:1)

Gitlab在此功能上有些bug。 如果您的项目很大,您可能会浪费很多时间进行故障排除。

最好的解决方案是使用创建/导入工具,不要忘记输入用户名和密码,否则根本不会导入任何内容。

关注我的截图

enter image description here

答案 9 :(得分:0)

您在gitlab中创建一个空项目,然后在本地终端上执行以下操作之一:

推送现有文件夹

cd existing_folder
git init
git remote add origin git@gitlab.com:GITLABUSERNAME/YOURGITPROJECTNAME.git
git add .
git commit -m "Initial commit"
git push -u origin master

推送现有的Git存储库

cd existing_repo
git remote rename origin old-origin
git remote add origin git@gitlab.com:GITLABUSERNAME/YOURGITPROJECTNAME.git
git push -u origin --all
git push -u origin --tags
相关问题