git - 通过 HTTP 推送到本地托管的 git 存储库

标签 git

我希望使用 python -m "SimpleHTTPServer" 命令推送到托管在 http://localhost:8000/tehCode.git 上的 git 存储库。

我收到一个错误

error: Cannot access URL http://localhost:8000/tehCode.git/, return code 22
fatal: git-http-push failed

我可以很好地克隆此存储库,但无法推送到它。 假设我仍想使用 Python SimpleHTTPServer,我该怎么做?

我已经看过了

  1. Cannot push Git to remote repository with http/https
  2. https://superuser.com/questions/473177/git-push-fatal-failed

但他们似乎在使用 Apache,并且大多数解决方案都是通过编辑 Apache 的配置文件。

最佳答案

当使用 SimpleHTTPServer 时,您使用的是所谓的哑 http 协议(protocol)。之所以称为 dumb,是因为它对 git 完全一无所知。因此,推送到这样的服务器是行不通的,因为 http 服务器不知道如何处理 git 发出的请求。

Git 有一个名为 git-http-backend 的 cgi 脚本,它允许使用智能 http 协议(protocol)推送 http。

我没有这方面的经验,但你可以看看 pythons CGIHTTPServer您可以将其定向到 git-http-backend。

但最简单的方法是使用 apache .

关于git - 通过 HTTP 推送到本地托管的 git 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15974286/

相关文章:

git - 查找作者修改的所有当前行

git - 将现有项目推送到 Github

git - git 的奇怪行为

ios - 如何组织一个使用 SVN 但依赖于使用 Git 的库的 xcode 项目?

git - 如何清除远程 github repo 中的所有提交

java - 运行 Git 命令并从 java 程序解析日志历史记录

git - VSTS : How to auto-delete git branches

Git 在将更新 merge 到我的子树时感到困惑

linux - Open vSwitch 无法在 Docker 上运行

python - 调用 Github.get_organization() 时出现 PyGithub BadCredentialsException