【问题标题】:GIT shared over HTTPS git-receive-pack fails通过 HTTPS 共享的 GIT git-receive-pack 失败
【发布时间】:2016-09-27 01:05:47
【问题描述】:

我正在尝试配置我自己的私有 git 服务器以使其通过 HTTP 可用,但我遇到了困难,我需要一些帮助。

我查看了几个关于如何通过 HTTP 提供 git 存储库的教程,我认为几乎所有部分都在正确的位置,因为目前我能够从不同工作站上的多个客户端克隆远程存储库,我也可以浏览带有 gitweb 应用程序的存储库。

我可以从客户端运行git commit 命令,但我无法将更改推送到主分支。

git push 命令记录以下错误:

remote: error: unable to create temporary file: Operation not permitted
remote: fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit

更新:经过多次测试,我设法从几个运行的客户端推送了四次。成功推送只是重复执行同一命令几次。这使我相信问题可能在于服务器端的一些过载问题,不允许接收更改,但我仍然无法理解缺少哪个配置。

环境如下:

$ uname -av
Linux odroid 3.8.13.30 #1 SMP PREEMPT Fri Feb 20 14:34:08 BRST 2015 armv7l armv7l armv7l GNU/Linux

$ apache2 -version
Server version: Apache/2.4.7 (Ubuntu)
Server built:   Jan 14 2016 17:49:32

$ git --version
git version 1.9.1

权限应该不是问题,因为存储库文件夹对运行 apache 服务的组具有 rw 权限

$ ls /var/git/repos
drwxrwx--- 0 odroid www-data 0 may 28 23:15 testremote.git
drwxrwx--- 0 odroid www-data 0 may 28 23:17 test

$ ps aux | grep apache
root      4524  0.0  0.8 107588 17836 ?        Ss   may25   0:17 /usr/sbin/apache2 -k restart
www-data  7797  0.0  0.4 107836  8372 ?        S    00:35   0:00 /usr/sbin/apache2 -k restart
www-data  7798  0.0  0.3 107636  7392 ?        S    00:35   0:00 /usr/sbin/apache2 -k restart
www-data  7799  0.0  0.4 107836  8300 ?        S    00:35   0:00 /usr/sbin/apache2 -k restart
www-data  7800  0.0  0.3 107692  7916 ?        S    00:35   0:00 /usr/sbin/apache2 -k restart
www-data  7801  0.0  0.3 107636  7392 ?        S    00:35   0:00 /usr/sbin/apache2 -k restart
www-data  7812  0.0  0.3 107636  7404 ?        S    00:35   0:00 /usr/sbin/apache2 -k restart

我当前的apache配置是:

            SetEnv GIT_PROJECT_ROOT /mnt/wh13/sandbox/git/repo/
            SetEnv GIT_HTTP_EXPORT_ALL 1
            SetEnv REMOTE_USER $REDIRECT_REMOTE_USER
            ScriptAliasMatch "(?x)^/git/\
                     (.*\.git/(HEAD|info/refs|objects/\
                     (info/[^/]+|[0-9a-f]{40}\.(pack|idx))|git-(upload|receive)-pack))$"\
                      /usr/lib/git-core/git-http-backend/$1

            ScriptAlias /git/ /usr/share/gitweb/
            ScriptLog ${APACHE_LOG_DIR}/cgi_log.log
            <Directory /usr/share/gitweb>
               Options +FollowSymLinks +ExecCGI
               AddHandler cgi-script .cgi
               DirectoryIndex gitweb.cgi
            </Directory>
            <Directory "/usr/lib/git-core*">
               Options ExecCGI Indexes
               AuthType Basic
               AuthName "GIT Repositories"
               AuthUserFile /mnt/wh13/sandbox/git/htpasswd.git
               Require valid-user
               Order allow,deny
               Allow from all
            </Directory>
            <Directory "/usr/share/gitweb/static">
               Options -ExecCGI +Indexes
               SetHandler default-handler
            </Directory>

我不明白哪些操作是不允许的,并且尝试使用 ScriptLog ${APACHE_LOG_DIR}/cgi_log.log 指令从 CGI 脚本中获取更多详细信息也没有提供任何有用的信息。

谁能提供一些关于如何进一步解决问题和解决问题的建议?

在此先感谢,很抱歉发了这么长的帖子

【问题讨论】:

  • 似乎错误在远程。尝试推送到本地 git repo。 mkdir tmp;cd tmp;git init --bare,然后去你的仓库运行git push tmp/ HEAD:master。如果本地没问题,恐怕你在服务器没有写权限。
  • 嗨 ElpieKay,我不确定我应该在哪里运行上面的命令,但我同意错误必须在服务器端的某个地方。当尝试使用拥有存储库的同一用户将更改从托管它的服务器推送到远程存储库时,也会发生这种情况。我很难理解的是如何获得更多关于哪些操作不允许的详细信息。

标签: git ubuntu-14.04


【解决方案1】:

遇到这些错误时,Git 2.21(2019 年第一季度)可能会更加健壮。

http-backend CGI 进程没有正确清理它产生的子进程以运行 upload-pack 等,当它自己死掉时,这已得到纠正。

commit 02818a9(2018 年 11 月 24 日)Max Kirillov (max630)
帮助者:Carlo Arenas (carlosJoseloMtz)
(由 Junio C Hamano -- gitster -- 合并于 commit ea8620b,2019 年 1 月 4 日)

http-backend:在exit 上启用清理分叉的upload/receive-pack

如果http-backend 因错误而死,则启动的upload-packreceive-pack 不会被杀死并等待,而是会继续运行一段时间,直到它们因标准输入关闭而退出。。 p>

这在工作环境中可能是不可取的,它也会导致t5562偶尔失败,因为进程保持打开act.err,有时在下次测试开始使用该文件后会出现错误。

通过在 http-backend 退出时启用命令清理来修复。

【讨论】:

    猜你喜欢
    • 2013-03-24
    • 2012-07-30
    • 2020-09-15
    • 2019-04-27
    • 2013-03-13
    • 2015-08-28
    • 1970-01-01
    • 2012-06-03
    • 2010-12-28
    相关资源
    最近更新 更多