http://www.cinsk.org/wiki/Git_over_SSH_or_HTTP

Git over SSH or HTTP

From Wiki

Note that this article is just for my personal use.  (Gentoo)

As far as I know, there are three ways to provide the GIT repository.

For my personal purpose, I've provided both 2nd and 3rd interfaces in addition to read-only web front-end.

Git over SSH

Setup git repositories in /var/lib/git.  Note that /var/lib/git itself is not managed by git.

With the user account, git can be used via ssh like:

git clone USERID@www.example.org:/var/lib/git/PROJECT

There is no anonymous interface.

If the SSH server uses non-standard port (except 22), you may specify in your $HOME/.ssh/config for the different port value.

Host www.example.org
   Port XXX

Git Over HTTP

Set up 99_mod_git.config in /etc/apache2/modules.d/ as following:

SetEnv GIT_PROJECT_ROOT /var/lib/git
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER

ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
Alias /gitweb/ /var/www/localhost/gitweb/

<Directory /usr/libexec/git-core/>
        Options ExecCGI FollowSymLinks Indexes
        AllowOverride AuthConfig
        Order allow,deny
        Allow from all
</Directory>

<Directory /var/lib/git>
        Options Indexes MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
</Directory>

<LocationMatch "^/git/.*/git-receive-pack$">
        Order allow,deny
        Allow from all
        AuthType Basic
        AuthName "Git http backend"
        AuthUserFile /etc/apache2/passwd.git
        Require valid-user          
        #<LimitExcept GET HEAD OPTIONS REPORT PROPFIND>
        #</LimitExcept>
</LocationMatch>

<Directory /var/www/localhost/gitweb/>
        AllowOverride All
        Options ExecCGI FollowSymLinks
        Order allow,deny
        Allow from all
</Directory>

/etc/apach2/passwd.git itself can be managed by htpasswd.

With the user account, git can be used like:

$ git clone http://USERID@www.example.org/git/PROJECT
password: ********

(Anonymous access) Without the user account, git can be used like:

$ git clone http://www.example.org/git/PROJECT
password: ********

It's possible that first clone the repository in anonymous, then later push the changes into the repository with the user account.

$ git clone http//www.example.org/git/PROJECT
$ cd PROJECT
$ # git commit to the local repository.
$ git config remote.origin.url http://USERID@www.example.org/git/PROJECT
$ git push

There is a read-only web front end in http://www.example.org/gitweb/.  I read some article that it is possible to provide the consistent URL (e.g. http://www.example.org/git/) for git command-line interface and the web frontend.  But I failed.  Currently, CLI uses http://www.example.org/git/PROJECT and front-end uses http://www.example.org/gitweb/PROJECT/.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值