我创建这个问题是为了帮助其他人在尝试推送初始化的 repo 时搜索有关两个 GitLab 配置问题的文档:
1:即使在 GitLab 前端设置 SSH key 后,您 GitLab 服务器上的 git 用户也需要密码:
$ git push -u origin master
git@hostname's password:
2:gitlab-shell 客户端在尝试推送时似乎在错误的位置查找您的存储库(/home/git/repositories
是所有存储库应按指定存储的位置在 /home/git/gitlab-shell/config.yml
中:
$ git push -v -u origin master
Pushing to git@hostname:sadmicrowave/test-project.git
fatal: 'sadmicrowave/test-project.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
最佳答案
当 SSH key 添加到 GitLab 前端时,我注意到它没有相应地添加到 /home/git/.ssh/authorized_keys
文件中。经过一番挖掘,我发现了这个 https://github.com/gitlabhq/gitlabhq/issues/3120它指出运行以下耙子:
rake gitlab:shell:setup RAILS_ENV=production
注意:引用省略了 RAILS_EVN=production
部分,但这是必需的,因此您不会收到另一个错误提示 cannot load such file -- rb-inotify
由于我的 git 用户没有 sudo
访问权限,我不得不从另一个使用 sudo 登录的用户运行上述命令,然后运行以下命令以将适当的权限 (git) 返回给 .ssh目录:
$ sudo chgrp -R git /home/git/.ssh
$ sudo chown -R git /home/git/.ssh
之后,返回 GitLab 前端,删除并重新创建您的 SSH key (您可以使用与之前相同的公钥)。
你应该在 /home/git/.ssh/authorized_keys
中看到正确的记录,如果你从你的本地机器运行 git push -v -u origin master
你现在应该好了!
关于GitLab v5.0 git push 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16179366/