git GitLab:无法将代码推送到服务器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15746336/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
GitLab: Can't push code to server?
提问by Joakim Engstrom
I've installed GitLab on an Ubuntu Server. Everything seems to work fine except I can't push/pull/clone to/from the server.
我已经在 Ubuntu 服务器上安装了 GitLab。一切似乎工作正常,除了我无法推/拉/克隆到/从服务器。
When I push I get the general error message:
当我推送时,我收到一般错误消息:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I've tried everything from hours of googling, but I can't seem to locate a problem.
我已经尝试了数小时的谷歌搜索,但我似乎无法找到问题所在。
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
Runs fine, OK across the board!
运行良好,全面OK!
I can SSH into [email protected] I get:
我可以通过 SSH 连接到 [email protected] 我得到:
PTY allocation request failed on channel 0
Welcome to GitLab, Anonymous!
When I do:
当我做:
ssh [email protected] "ls /location/of/git/dir"
I get:
我得到:
Not allowed command
The website is running, when I create a repository on the site it appears in /home/git/repository/
该网站正在运行,当我在网站上创建一个存储库时,它出现在 /home/git/repository/
But I still can't push to it.
但我仍然无法推动它。
I followed this guide:
我遵循了本指南:
https://github.com/gitlabhq/gitlabhq/blob/5-0-stable/doc/install/installation.md
https://github.com/gitlabhq/gitlabhq/blob/5-0-stable/doc/install/installation.md
and this guide to get it running on apache:
以及让它在 apache 上运行的本指南:
http://shanetully.com/2012/08/running-gitlab-from-a-subdirectory-on-apache/
http://shanetully.com/2012/08/running-gitlab-from-a-subdirectory-on-apache/
采纳答案by Joakim Engstrom
I finally figured it out after many hours of debugging, and I somehow knew there was a simple issue with the configuration.
经过数小时的调试,我终于弄明白了,我不知何故知道配置存在一个简单的问题。
Since the second guide mention how to set up gitlab on apache with a relative url you actually have to do some more configs inside gitlab. I uncommented the line about relative url:s unicorn.rb and in gitlab-shell/config I added my whole URL (with subdirectory).
由于第二个指南提到了如何使用相对 url 在 apache 上设置 gitlab,因此您实际上必须在 gitlab 中进行更多配置。我取消了关于相对 url:s unicorn.rb 的注释,并在 gitlab-shell/config 中添加了我的整个 URL(带有子目录)。
Before:
前:
http://web-adress.com/
after:
后:
http://web-adress.com/subdomain/
Now it works great.
现在效果很好。
回答by Troy Klein
You can test it with the command bellow. When you login it should say your name.
您可以使用下面的命令对其进行测试。当您登录时,它应该显示您的姓名。
ssh -T [email protected]
ssh -T [email protected]
Welcome to GitLab, Christian Hammer!
欢迎来到 GitLab,Christian Hammer!
If it says "Welcome to GitLab, Anonymous!" gitlab does not recognise you as a user of gitlab.
如果它说“欢迎来到 GitLab,匿名!” gitlab 无法将您识别为 gitlab 的用户。
回答by Pascal
To be more precise regarding the accepted answer ("answered Apr 6 at 17:23" and "edited Jul 21 at 10:07" by "Joakim Engstrom"):
为了更准确地了解已接受的答案(“Joakim Engstrom”的“4 月 6 日 17:23 回答”和“7 月 21 日 10:07 编辑”):
You're most probably in the situation where you updated Gitlab to fit your own context path (that's accessing it from http://localhost/<my_context_path>
and not http://localhost
).
您很可能处于更新 Gitlab 以适应您自己的上下文路径的情况(即从http://localhost/<my_context_path>
而非访问它http://localhost
)。
In the how-tos for this, is not mentionned to also modify this gitlab-shell configuration file:
在这个的操作方法中,没有提到还要修改这个 gitlab-shell 配置文件:
// logout any Gitlab open session, stop your Gitlab service, and your possible third-party webserver first
$ sudo service apache2 stop
$ sudo service gitlab stop
// perform the modification that fixes it, if you indeed configured Gitlab to be accessed with a custom context path
$ sudo -u git -H nano ~git/gitlab-shell/config.yml
# Url to gitlab instance. Used for api calls. Should end with a slash.
-gitlab_url: "http://localhost/"
+gitlab_url: "http://localhost/<my_context_path>/"
// restart services
$ sudo service gitlab start
$ sudo service apache2 start
// Try to push again from your particular Gitlab user local repository, to the Gitlab remote repository
$ cd <path_to_my_local_repository>
$ sudo -u <OS_username_that_owns_the_local_repository> -H git push -u origin master
Counting objects: 3202, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3115/3115), done.
Writing objects: 100% (3202/3202), 11.56 MiB | 5.34 MiB/s, done.
Total 3202 (delta 609), reused 0 (delta 0)
To `git@<my_FQDN>:<my_Gitlab_user_or_group_name>/<my_gitlab_project_ID>.git`
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
$
About "similar to stackoverflow.com/questions/13071234/… – Paul Verest Jul 18 at 6:20" (Can't push to new gitlab install):
No, this is not the same issue in this page topic.
关于“类似于 stackoverflow.com/questions/13071234/... – Paul Verest 7 月 18 日 6:20”(无法推送到新的 gitlab 安装):
不,这不是本页面主题中的同一问题。
回答by Troy Klein
I do not know if you have resolved this yet but what I found is if I generate a key with the email address I used in gitlab the process works. Steps I took:
我不知道你是否已经解决了这个问题,但我发现如果我用我在 gitlab 中使用的电子邮件地址生成一个密钥,这个过程是有效的。我采取的步骤:
ssh-keygen -t rsa -C "#email address#"
Creates a new ssh key using the provided email.
使用提供的电子邮件创建新的 ssh 密钥。
Generates public/private RSA key pair.
生成公钥/私钥 RSA 密钥对。
Next just use code below to dump your public key and add to GitLab SSH Keys
接下来只需使用下面的代码转储您的公钥并添加到 GitLab SSH 密钥
cat ~/.ssh/#key name#.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6eNtGpNGwstc....*
回答by Michael Kowhan
In my case the reason was an enforced redirect to https by nginx. Check if the git user can use the gitlab-api by running
就我而言,原因是 nginx 强制重定向到 https。检查 git 用户是否可以通过运行来使用 gitlab-api
sudo -u git -H /home/git/gitlab-shell/bin/check
on the server. In my case the output was
在服务器上。在我的情况下,输出是
Check GitLab API access: FAILED. code: 301
I had to change the gitlab_url
in /home/git/gitlab-shell/config.yml
to https://<domain>
我不得不改变gitlab_url
在/home/git/gitlab-shell/config.yml
以https://<domain>
回答by user264860
for me it was because i had restricted who could ssh into my server in /etc/ssh/sshd_config AllowUsers git
对我来说,这是因为我在 /etc/ssh/sshd_config AllowUsers git 中限制了谁可以 ssh 进入我的服务器