git-http-backend / nginx - 推送

时间:2017-10-16 14:09:49

标签: git nginx git-http-backend

我有一个在线服务器(Ubuntu 17.04)托管我的裸机。我尝试在这台服务器上设置HTTPS,我可以拉,但我无法推送,它失败并出现以下错误:

  

错误:无法访问网址https://user:passwd@myserver.com/REPO/,   返回代码22致命:git-http-push失败错误:无法推送一些   引用'https://user:passwd@myserver/REPO/'

nginx配置相关部分看起来像这样:

# static repo files for cloning over https
location ~ ^.*\.git/objects/([0-9a-f]+/[0-9a-f]+|pack/pack-[0-9a-f]+.(pack|idx))$ {
    client_max_body_size 0;
    auth_basic  "Restricted Area";
    auth_basic_user_file /etc/apache2/.htpasswd;
    fastcgi_param REMOTE_USER $remote_user;
    root /home/git/;
}

# requests that need to go to git-http-backend
location ~ ^.*\.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ {
    client_max_body_size 0;
    auth_basic  "Restricted Area";
    auth_basic_user_file /etc/apache2/.htpasswd;
    root /home/git/;

    #fastcgi_pass unix:/var/run/fcgiwrap.socket;
    fastcgi_param SCRIPT_FILENAME   /usr/lib/git-core/git-http-backend;
    fastcgi_param PATH_INFO         $uri;
    fastcgi_param GIT_PROJECT_ROOT  /home/git/;
    fastcgi_param GIT_HTTP_EXPORT_ALL "";
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param REMOTE_USER $remote_user;
    include fastcgi_params;
}

在我阅读的所有帖子中,问题来自REMOTE_USER fastcgi param或远程URL中缺少user / passwd的本地git配置,但我设置了这个,所以我无能为力。有没有人有想法或看到问题?

编辑:这是我的.git / config:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
[remote "origin"]
    url = https://user:passwd@myserver.com/REPO/
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[user]
    name = git

1 个答案:

答案 0 :(得分:0)

如果不重现您的设置,您确定receivepack根据https://www.jimbobbennett.io/opening-multiple-solutions-in-visual-studio-for-mac/正确启用了吗?

如果您尝试更新documentation中的本地.git/config网址(请查看评论)