我以某种方式删除了代码分支的整个目录。我克隆了一个新的。除了推动之外,它工作得很好。
~/workspace/wtf (mybranch)]$ git push origin mybranch
error: Cannot access URL [my url], return code 22
fatal: git-http-push failed
Run Code Online (Sandbox Code Playgroud)
不过 git pull 有效。我该如何解决?
小智 33
我错误地使用 https 而不是 ssh 来创建新副本。从那以后,我进行了修改和提交,但由于明显的原因无法推动。
为了恢复,我简单地将 .git/config 中的 [remote "origin"] 部分从
到
url = git@github.com:AIFDR/riab_core.git
在那之后,我可以再次推动。
小智 14
自 git 1.6.6 以来新的“smart-http”支持。新方法允许一次传输整个包,而不是作为单个文件传输。
您还可以使用 gitweb 在同一位置提供可浏览的 URL。
注意:因为访问是由 apache 控制的,所以您可以将任何 Auth 要求(htaccess 或 ldap 等)添加到每个存储库的设置中。
此答案假定您拥有远程服务器并希望添加/修复 http 支持。
首先:检查 apache 日志,当 apache 尝试执行 git-http-backed cgi 脚本时,它可能是权限被拒绝/无法定位错误。
新建一个 git_support.conf 文件,并包含在 apache 中(在 httpd.conf 中添加 include 语句)
#
# Basic setup for git-http-backend
#
SetEnv GIT_PROJECT_ROOT /opt/git_repos
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER #IMportant !!! This could be your problem if missing
<Directory /opt/git> # both http_backend and gitweb should be somewhere under here
AllowOverride None
Options +ExecCGI -Includes #Important! Lets apache execute the script!
Order allow,deny
Allow from all
</Directory>
# This pattern matches git operations and passes them to http-backend
ScriptAliasMatch \
"(?x)^/git/(.*/(HEAD | \
info/refs | \
objects/(info/[^/]+ | \
[0-9a-f]{2}/[0-9a-f]{38} | \
pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
git-(upload|receive)-pack))$" \
/opt/git/libexec/git-core/git-http-backend/$1
# Anything not matched above goes to displayable gitweb interface
ScriptAlias /git /opt/git/cgi-bin/gitweb.cgi/
Run Code Online (Sandbox Code Playgroud)
结果是推/拉的能力:
me@machine /tmp/eddies $ git pull
Already up-to-date.
me@machine /tmp/eddies $ touch changedFile
me@machine /tmp/eddies $ git add .
me@machine /tmp/eddies $ git commit -am"commiting change"
[master ca7f6ed] commiting change
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 changedFile
me@machine /tmp/eddies $ git push origin master
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 239 bytes, done.
Total 2 (delta 1), reused 0 (delta 0)
To http://mysecretdomain.com/git/eddies
0f626a9..ca7f6ed master -> master
Run Code Online (Sandbox Code Playgroud)
您可以在线浏览这些更改。

来源:http : //repo.or.cz/w/alt-git.git?a= blob_plain; f= gitweb/ README
要通过 http启用“ git push ”,您必须在网络服务器上启用 WebDAV。要为 Apache Webserver 执行此操作,只需编辑配置文件:
vim /etc/httpd/conf/httpd.conf
Run Code Online (Sandbox Code Playgroud)
然后搜索以以下开头的行:
<Directory "/var/www/html">
Run Code Online (Sandbox Code Playgroud)
在它后面添加以下行:
Dav On
Run Code Online (Sandbox Code Playgroud)
确保您在 httpd.conf 中也有以下行未注释:
LoadModule dav_fs_module modules/mod_dav_fs.so
Run Code Online (Sandbox Code Playgroud)
之后你就准备好了。使用以下命令重新启动 Apache Webserver:
service httpd restart
Run Code Online (Sandbox Code Playgroud)
还要确保服务器上的所有 git 存储库文件都可以由 pache:apache 用户和组使用:
chown -R apache:apache /var/www/html/your_git_repository
Run Code Online (Sandbox Code Playgroud)
否则,在执行“git push”时未能设置正确的权限将导致“PUT error: curl result=22, HTTP code=403”。
现在只需从您的客户端机器上执行“git push”,一切都应该可以正常工作。
小智 4
您无法推送通过 HTTP 克隆的存储库。您需要将 URL 更新为 assh://或git://type URL。
| 归档时间: |
|
| 查看次数: |
47188 次 |
| 最近记录: |