简体   繁体   English

Git +智能Http(s):403错误

[英]Git + Smart Http(s): 403 Error

Although i have read many posts, I was not able to solve this problem. 尽管我读了很多文章,但无法解决此问题。
I want to use Git + Smart Http, using a remote repository on my rasperry pi. 我想在树莓派上使用远程存储库来使用Git + Smart Http。
I'm running on Arch Linux. 我在Arch Linux上运行。
First, let's consider an Http configuration (and not https), for semplicity. 首先,让我们考虑一下Http配置(而不是https)。
Apache and Git are correctly installed on my Rasperry Pi, and the port for the Http connection is 8080. Apache和Git已正确安装在我的Rasperry Pi上,并且Http连接的端口为8080。

On my Raspberry Pi: 在我的Raspberry Pi上:

1. I have uncommented in /etc/httpd/conf/http.conf the lines about mod_cgi, mod_alias, and mod_env 1.我没有在/etc/httpd/conf/http.conf中注释有关mod_cgi,mod_alias和mod_env的行

2. I have added to /etc/httpd/conf/http.conf these lines: 2.我在/etc/httpd/conf/http.conf中添加了以下几行:

SetEnv GIT_PROJECT_ROOT /srv/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/lib/git-core/git-http-backend/

<Directory "/usr/lib/git-core*">
    Require all granted
</Directory>
  1. I have created the directory /srv/git 我已经创建了目录/ srv / git

     # mkdir -p /srv/git 

  2. I have created and initialized a git repository: 我已经创建并初始化了一个git仓库:

     # mkdir -p /srv/git/test.git 
     # git init --bare 

  3. I have changed owner and group of the repo: 我更改了仓库的所有者和组:

     # chown -R http:http /srv/git/test.git 

On my client: 在我的客户上:

  1. I have cloned the repo inside the folder 我已经将存储库克隆到了文件夹中

     $ git clone http://address:8080/git/test.git 

  2. I have created and added a new file and I have committed 我创建并添加了一个新文件,并且已经提交

     $ nano test.c 
     $ git add test.c 
     $ git commit -m 'first' 

  3. I have pushed the new project on my Rasperry Pi 我已经在Rasperry Pi上推送了新项目

     $ git push origin master 

But I have this error: 但是我有这个错误:

atal: unable to access 'address:8080/git/test.git/';: The requested URL returned error: 403

If you clone the repo inside the test folder (in which you initialized a git repo), that means you have: 如果克隆的测试文件夹的回购(在你初始化的混帐回购协议),这意味着你必须:

test/test

If you are pushing from the first test folder, that repo would not have any origin. 如果从第一个测试文件夹中推送,则该存储库将没有任何来源。

Try in instead to remove any test folder, and start over with: 尝试尝试删除所有测试文件夹,然后重新开始:

git clone http://address:8080/git/test.git
cd test
# work
git add .
git commit -m "work"
git push -u origin master

Regarding the 403 error, I would recommand on the server Apache (2.4) side: 关于403错误,我将在服务器Apache(2.4)端重新命令:

<Directory "/usr/lib/git-core*">
   Options ExecCGI Indexes
   Order allow,deny
   Allow from all
   Require all granted
</Directory>

And: 和:

<LocationMatch "^/.*/git-receive-pack$">
    Options +ExecCGI
    Require all granted
</LocationMatch>
<LocationMatch "^/.*/git-upload-pack$">
    Options +ExecCGI
    Require all granted
</LocationMatch>

Also, on the server, in the git bare repo folder: 另外,在服务器上的git nude repo文件夹中:

cd /srv/git/test.git
git config --file config http.receivepack true

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

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