将现有的本地 Git 主仓库导入 Gitlab:Git 用户访问问题

9
我在测试服务器上有一个git主分支,路径为testvps.subdomain.domain.com:~public_html/domain.com/ZendSkeletonApplication/。现在我在同一台服务器上运行了Gitlab CentOS rpm,地址为http://testvps.subdomain.domain.com:8888

将本地主库导入Gitlab

我需要将这个现有的本地仓库导入到Gitlab(请参见早期关于使用ssh克隆repo的问题here)。此仓库是主分支而不是原始分支源,原始分支源在Github上是ZendApplication。对于密码访问,Gitlab建议使用链接https://username:password@gitlab.com/company/project.git。文档提到要将裸仓库复制到/home/git/。

最佳方法是什么?

用户git已经被添加,但是家目录似乎没有自动生成,可能需要手动创建 - 参见链接here。不确定是否需要正确导入。由于这是主分支,似乎需要不同的方法来导入现有的git仓库,它有20多个提交。也许我应该将主分支作为新的源?我该如何操作?

更新

我已经将Gitlab .git仓库添加为新的远程仓库。
git remote set-url origin git@testvps.sub.domain.com:root/repo.git
git remote -v
origin  git@testvps.sub.domain.com:root/repo.git (fetch)
origin  git@testvps.sub.domain.com:root/repo.git (push)

当我尝试推送内容时,会要求输入git用户的密码。

git push -u origin master
git@testvps.sub.domain.com's password: 

我不需要它,也不应该需要它。我该如何解决这个问题?

PS sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production 不起作用,因为它提到了缺少命令的bundle。


1
如果您在GitLab前端添加一个新存储库并将其URL设置为现有存储库的URL,会发生什么? - orbrey
在这里阅读有关添加本地远程的内容:https://dev59.com/Im435IYBdhLWcg3w50f4 - rhand
1
你可以在URL中将localhost替换为通过GitLab进行的http checkout吗? - orbrey
http://localhost:~/public_html/domain.com/ZendSkeletonApplication/无法工作。本地主机也无法工作。仓库不大,肯定是其他问题。想知道如何调试。Gitlab访问和错误日志未报告在`/var/log/gitlab/nginx/gitlab_error.log`或`/var/log/gitlab/nginx/gitlab_access.log`中的问题。 - rhand
看到这个错误 xx.xxx.xx.xxx - - [30/Jul/2014:14:46:42 +0200] "GET /public_html/domain.com/ZendSkeletonApplication/info/refs?service=git-upload-pack HTTP/1.1" 404 2529 "-" "git/1.8.5.3",使用链接 http://testvps.subdomain.domain.com:~/public_html/domain.com/ZendSkeletonApplication/。 - rhand
显示剩余6条评论
3个回答

4

您可能想要使用rake gitlab:import:repos

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

所有者将成为第一个管理员,如果不存在,则会创建一个组。

另请参阅:如何将现有的裸Git存储库导入Gitlab?


1

一旦您解决了用户访问问题:

  1. 在GitLab上创建一个与本地项目同名的新项目。
  2. 在本地执行以下操作:git remote add origin git@repo-url:projectpath/projectname.git
  3. git push

0

在另一位服务器管理员的帮助下,我解决了问题。例如,我需要按照这里描述的方式生成并添加一个SSH密钥http://www.codeproject.com/Articles/674637/How-to-passwordless-ssh。不知何故,在安装Gitlab时未处理此问题。因此,已生成一个密钥并将其添加到授权密钥中:

ssh-keygen -t rsa
Generating public/private rsa key pair.
//store in home directory of user and then copy to authorized keys at destination
cat /user/.ssh/id_rsa.pub >>  /var/opt/gitlab/.ssh/authorized_keys

另外,Gitlab存储库的路径不正确。所有存储库都位于这里:/var/opt/gitlab/git-data/repositories/,而我的存储库位于我的用户名下 - 目前是jasper - 因此路径为git@testvps.domain.com:/var/opt/gitlab/git-data/repositories/jasper/repo.git

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接