无法使用 http/https 将 Git 推送到远程存储库
我在服务器上的 apache 提供的目录中有一个 Git 存储库。我已经配置了 WebDAV 并且它似乎运行正常。 Litmus 返回 100% 成功。
我可以从远程主机克隆我的存储库,但是当尝试推送 http 或 https 时,出现以下错误:
错误:无法访问 URL https://git.example.com/repo/,返回代码 22 致命:git-http-推送失败
有什么想法吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
编辑 .git/config 文件的以下部分:
然后
尝试
git Push origin master
。根据需要编辑其他存储库 URL 的配置文件中的身份验证详细信息,然后推送到所需的分支。
Edit the following section of your .git/config file:
to
Then try
git push origin master
.Edit the authentication details in your config files for other repository URLs as required and push to the required branch.
强烈建议尽可能不要使用 WebDAV。如果必须使用 HTTP/HTTPS,则使用 建议使用 git-http-backend CGI 脚本而不是 WebDAV。
It is highly suggested NOT to use WebDAV if possible. If you must use HTTP/HTTPS then usage of the git-http-backend CGI script is recommended over WebDAV.
就像这个发表评论,您的
/Web/git/Logs/ErrorLog
对于该错误有何评论?正如埃迪在评论中和 Arrowmaster 在他的(已投票)答案,智能 http 协议 现在是最新 Git 发行版的一部分。
git-http-backend< /code>
CGI 脚本可以通过 http 处理任何 git 命令。
Git 2.17(2018 年第 2 季度)将添加调试辅助功能。
请参阅 提交 a2b9820(2018 年 1 月 24 日),作者:Patryk Obara(
梦想家
)。(由 Junio C Hamano --
gitster
-- 合并于 提交 39a1dd8,2018 年 2 月 13 日)As in this post comment, what does your
/Web/git/Logs/ErrorLog
says about that error?As mentioned by Eddie in the comments and by Arrowmaster in his (upvoted) answer, the smart http protocol is now part of recent Git distribution.
The
git-http-backend
CGI script can takes care of any git commands through http.Git 2.17 (Q2 2018) will add a debugging aid.
See commit a2b9820 (24 Jan 2018) by Patryk Obara (
dreamer
).(Merged by Junio C Hamano --
gitster
-- in commit 39a1dd8, 13 Feb 2018)您可能需要将用户添加为存储库的成员,并可能需要更新权限。
我们必须与每个将在我们组织的 github 存储库上做出贡献的成员一起这样做。
you might need to add the user as a member for the repository and possibly update permissions.
we had to do this with each member that will be contributing on our organizations github repository.
我在 Windows 上遇到了同样的问题,我的凭据存储在 Windows 凭据管理器中。我不希望每个用户都必须编辑配置文件,因此我更改了 http://example.com 的网址到 http://[电子邮件受保护] 即使我的 id 不是 git,它也能工作。我不认为用户“git”在任何地方定义,并假设任何名称都可以工作。 (如果您不在专用网络上,请确保使用 https)。
I had the same issue on Windows where my credentials are stored in windows credential manager. I did not want every user to have to edit the config file so I changed the url from http://example.com to http://[email protected] and it work even though my id is not git. I don't think a user "git" is defined anywhere and assume any name will work. (If you are not on a private network make sure you use https).
我遇到了类似的问题,我能够使用 HTTP 协议从存储库中克隆和拉取,但无法推送。我通过执行以下操作解决了这个问题。
我更改了项目 .git/config 文件中远程的 url 以匹配 GitHub SSH url。然后,我按照“https://help.github”中的所有说明进行操作。 com/articles/generate-ssh-keys#platform-linux”并使用“https://help.github.com/articles/error-permission-denied-publickey"。最好的部分是我没有处理 Apache 或更改远程服务器上的任何 HTTP 设置。
I had a similar issue in which I was able to clone and pull from the repository using the HTTP protocol, but I was not able to push. I solved this by doing the following.
I changed the url for the remote in the project's .git/config file to match the GitHub SSH url. I then followed all of the instructions at "https://help.github.com/articles/generating-ssh-keys#platform-linux" and troubleshooted with "https://help.github.com/articles/error-permission-denied-publickey". The best part is that I did not have deal with Apache or change any HTTP settings on the remote server.
使用 gitweb 启用写入经过验证的 git dav 虚拟主机的示例可以解决您的问题:
然后只需使用您的用户克隆您的存储库:
当您尝试推送时,它会询问您的密码并提供密码。
将密码放在克隆 URL 中是一种不好的安全做法,因为任何人都可以在 .git/config 中读取它。
En example of write authentified git dav virtualhost with gitweb enable that could solve your problem :
Then just clone your repository with your user :
And when you will try to push it will ask your password and provide it.
Placing the password in the clone url is a security bad practice as anyone can read it in your .git/config.