简体   繁体   English

GitLab:无法将代码推送到服务器?

[英]GitLab: Can't push code to server?

I've installed GitLab on an Ubuntu Server. 我在Ubuntu服务器上安装了GitLab。 Everything seems to work fine except I can't push/pull/clone to/from the server. 一切似乎工作正常,除了我不能推/拉/克隆到服务器/从服务器。

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! 运行良好,全面运行!

I can SSH into git@adress.adress I get: 我可以通过SSH连接到git@adress.adress我得到:

PTY allocation request failed on channel 0
Welcome to GitLab, Anonymous!

When I do: 当我做:

ssh git@adress.adress "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/

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. 由于第二个指南提到了如何使用相对url在apache上设置gitlab,你实际上必须在gitlab中做一些更多的配置。 I uncommented the line about relative url:s unicorn.rb and in gitlab-shell/config I added my whole URL (with subdirectory). 我取消了关于相对url:s unicorn.rb的行,并在gitlab-shell / config中添加了我的整个URL(带子目录)。

Before: 之前:

 http://web-adress.com/

after: 后:

 http://web-adress.com/subdomain/

Now it works great. 现在它很棒。

You can test it with the command bellow. 您可以使用bellow命令对其进行测试。 When you login it should say your name. 登录时应该说出你的名字。

ssh -T git@myserver.com ssh -T git@myserver.com

Welcome to GitLab, Christian Hammer! 欢迎来到GitLab,Christian Hammer!

If it says "Welcome to GitLab, Anonymous!" 如果它说“欢迎使用GitLab,匿名!” gitlab does not recognise you as a user of gitlab. gitlab不承认你是gitlab的用户。

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. 我不知道你是否已经解决了这个问题,但我发现如果我使用gitlab中使用的电子邮件地址生成密钥,则该过程可以正常工作。 Steps I took: 我采取的步骤:

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....*

To be more precise regarding the accepted answer ("answered Apr 6 at 17:23" and "edited Jul 21 at 10:07" by "Joakim Engstrom"): 关于接受的答案(“4月6日17:23回答”和“Joakim Engstrom编辑的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: 在how-to中,没有提到也要修改这个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 ): 关于“类似于stackoverflow.com/questions/13071234 / ... - Paul Verest 7月18日6:20”( 无法推送到新的gitlab安装 ):
No, this is not the same issue in this page topic. 不,这不是此页面主题中的相同问题。

In my case the reason was an enforced redirect to https by nginx. 在我的情况下,原因是由nginx强制重定向到https。 Check if the git user can use the gitlab-api by running 检查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>

对我来说这是因为我限制谁可以在/ etc / ssh / sshd_config中使用ssh进入我的服务器AllowUsers git

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM