Apache 如何允许通过http匿名推送到git存储库?
我在这里找不到一个例子:Apache 如何允许通过http匿名推送到git存储库?,apache,git,Apache,Git,我在这里找不到一个例子: 有可能吗?只是不要在Apache配置中放入任何AuthType(因此没有LocationMatch或Location元素) 如果您没有AuthType,这意味着您的Apache只需将您的git请求传递给cgi程序GitHTTP后端 因此,在这种情况下不会进行身份验证:可以进行匿名推送。将此添加到httpd.conf(假设/srv/git包含您的repo) 在服务器上创建的存储库中打开.git/config并添加以下内容 [http] receivepack =
有可能吗?只是不要在Apache配置中放入任何
AuthType
(因此没有LocationMatch
或Location
元素)
如果您没有AuthType,这意味着您的Apache只需将您的git请求传递给cgi程序GitHTTP后端
因此,在这种情况下不会进行身份验证:可以进行匿名推送。将此添加到httpd.conf(假设/srv/git包含您的repo) 在服务器上创建的存储库中打开.git/config并添加以下内容
[http]
receivepack = true
最后是在存储库根运行中
git config --bool core.bare true
或者,如果您想查看服务器上可用的文件(用于网站或其他任何地方),则忽略上述命令,并使用此命令编辑.git/config
[receive]
denyCurrentBranch = false
然后在服务器上运行这个当你想更新目录(一定有更好的方法,所以请让我知道)
使用git http后端和gitweb进行匿名推送和浏览
请注意,DAV比git 1.6.6以来新的“智能http”支持慢得多。新方法允许一次传输整个包,而不是作为单个文件
下面的设置消除了在每个repo(http.receivepack)中对自定义配置的需要,或者对硬重置的需要。只需使用
git --bare init --shared
您还可以使用gitweb在同一位置提供可浏览的URL 注意:因为访问是由apache控制的,所以您可以向每个存储库的设置中添加任何身份验证要求(htaccess或ldap等)
只需创建一个新的git_support.conf文件,并将其包含在apache中(在httpd.conf中添加include语句) 您可以在线浏览这些更改。。 资料来源:
您好,我没有
AuthType
,但我仍然收到此消息错误:无法访问URLhttp://localhost/git/test/,返回代码22
git从该位置克隆fine@tm1rbrt:可以help@tm1rbt:保留2个
元素及其选项+ExecCGI
,但不保留其他内容(与身份验证相关),这应该是可行的。关键是要确保CGI被执行,否则,它依赖于WEBDAV,这将触发错误22。感谢SetEnv REMOTE\u USER=$REDIRECT\u REMOTE\u USER
line。我花了一个小时在谷歌上搜索为什么在配置其他所有内容时得到403。
[receive]
denyCurrentBranch = false
git reset --hard
git --bare init --shared
#
# 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