私有git存储库通过http

时间:2010-02-17 07:07:23

标签: git http

你能推荐任何简单的解决方案来设置一个可通过http访问的git存储库(s,有建议的cleutus)吗?我有自己的http服务器,我想用它来托管一些小的私人项目。在家我可以ssh它,但在工作防火墙让我不这样做。

有没有免费的方法来设置一个小的私人git存储库,我可以通过http推送/获取,以便我可以在家庭和工作之间共享项目?提前谢谢!

2 个答案:

答案 0 :(得分:22)

Git原生支持这一点。当然,您需要一台HTTP服务器。

将您的(裸)存储库放在Web服务器可以访问的文件夹中。在该目录中,运行以下命令:

$ git --bare update-server-info
$ mv hooks/post-update.sample hooks/post-update

第一个命令提供额外信息,以便Web服务器知道如何处理存储库。第二个命令确保在有人推送到存储库时随时更新信息。

您可以在此处找到该信息:http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#setting-up-a-public-repository

答案 1 :(得分:1)

不需要webDAV

而且,自从git 1.6.6以来,DAV明显慢于新的“smart-http”支持。新方法允许一次传输整个包,而不是单个文件。


您还可以使用gitweb在同一位置提供可浏览的网址。

注意:由于访问权限由apache控制,因此您可以将任何身份验证要求(htaccess或ldap等)添加到每个存储库的设置中。


只需创建一个新的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

您可以在线浏览这些更改.. gitweb provides a browsable interface

来源: http://repo.or.cz/w/alt-git.git?a=blob_plain;f=gitweb/README

相关问题