我有一个在线服务器(Ubuntu 17.04)来托管我的裸仓库。我试图在这台服务器上设置 HTTPS,我可以拉,但我不能推,它失败并出现以下错误:
错误:无法访问 URL https://user:passwd@myserver.com/REPO/,返回代码 22 致命:git-http-push failed 错误:无法将一些参考推送到' https://user:passwd@myserver/回购/ '
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;
}
在我读到的所有线程中,问题来自远程 URL 中缺少用户/密码的 REMOTE_USER fastcgi 参数或本地 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