仅使用 git 实现更快的 HTTP 推送 - 不需要 webDAV
自 git 1.6.6 以来新的“smart-http”支持。新方法允许一次传输整个包,而不是作为单个文件。
您还可以使用 gitweb 在同一位置提供可浏览的 URL。
注意:由于访问是由 apache 控制的,因此您可以将任何 Auth 要求(htaccess 或 ldap 等)添加到每个存储库的设置中。
此答案假定您拥有远程服务器并希望添加/修复 http 支持。
第一:
检查 apache 日志,当 apache 尝试执行 git-http 支持的 cgi 脚本时,可能是权限被拒绝/无法定位错误。
为 git 添加 HTTP 支持
只需新建一个 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/
结果是推/拉的能力:
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
您可以在线浏览这些更改..
来源:
http://repo.or.cz/w/alt-git.git?a=blob_plain;f=gitweb/README