Git + Smart Http(s): 403 Error



尽管我读了很多帖子,我还是没能解决这个问题。
我想使用Git + Smart Http,在我的rasperry pi上使用远程存储库。
我用的是Arch Linux。
首先,为了简单起见,让我们考虑一个Http配置(而不是https)。我的raspperry Pi上已经正确安装了Apache和Git,并且Http连接的端口是8080。

在我的树莓派上:

1. 我在/etc/httpd/conf/http.conf中取消了关于mod_cgi, mod_alias和mod_env的注释

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>
  • 我已经创建了目录/srv/git

    # mkdir -p /srv/git

  • I have created and initialized a git repository:

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

  • 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

      $ git push origin master

    But I have this error:

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

    如果您将repo 克隆到测试文件夹中(您在其中初始化了git repo),则意味着您有:

    test/test
    

    如果你从第一个测试文件夹推送,那么这个repo将没有任何起源。

    尝试删除任何测试文件夹,并重新开始:

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

    关于403错误,我建议在服务器端Apache (2.4):
    <Directory "/usr/lib/git-core*">
       Options ExecCGI Indexes
       Order allow,deny
       Allow from all
       Require all granted
    </Directory>
    

    :

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

    同样,在服务器端,在git bare repo文件夹中:

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

    相关内容

    • 没有找到相关文章

    最新更新