Setup git over HTTP server
Setup git over HTTP server
To setup git over HTTP server use following steps:
- Install package git
- Choose a base folder for all git repositories, for example, '/var/www/git'
- Configure '/etc/httpd/conf/httpd.conf' virtual host for git using:
- SetEnv GIT_PROJECT_ROOT /var/www/git
- SetEnv GIT_HTTP_EXPORT_ALL
- ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
- Use following steps to create a test repository
- cd var/www
- mkdir git
- cd git
- mkdir test
- cd test
- git init --bare
- cd /var/www
- chown -R apache:apache git
- Now users can clone test repository using:
- git clone http://<server_ip_or_name>/git/test
- One changes are done locally they can be pushed to server using:
- git push origin master
Configuring HTTP authentication for repository on server
To configure HTTP authentication for repository on server use steps mentioned at Configuring LDAP based authentication for apache. Note that for git repository the authentication configuration should be done with LocationMatch for URLs starting with "/git/<repository_name>". For example to enable authentication for test repository created above use:
<LocationMatch "^/git/test.*$">
Options all
Order deny,allow
Deny from All
AuthType Basic
AuthName "Test1 git repository"
AuthBasicProvider ldap
AuthzLDAPAuthoritative on
AuthLDAPURL ldap://ldap.virtual-labs.ac.in:389/ou=people,dc=virtual-labs,dc=ac,dc=in?uid
AuthLDAPGroupAttribute memberUid
AuthLDAPGroupAttributeIsDN off
Require ldap-group cn=admin,ou=groups,dc=virtual-labs,dc=ac,dc=in
Require ldap-attribute gidNumber=501
Satisfy any
</LocationMatch>
This information is provided here for fast access. For detailed information on configuring LDAP authentication for apache refer to Configuring LDAP based authentication for apache
Configuring HTTP authentication on client
To configure HTTP authentication for git on client create a file '.netrc' in users home folder with following details:
machine <server_name_or_ip> login <http_username> password <http_password>
After this use 'git clone' or 'git push' as usual for configured server and git will automatically use above configured authentication.