Difference between revisions of "Setup git over HTTP server"
m |
m |
||
Line 18: | Line 18: | ||
#:: mkdir test | #:: mkdir test | ||
#:: cd test | #:: cd test | ||
#:: git init --bare | #:: git init --bare --shared | ||
#:: git config --file config http.receivepack true | |||
#:: cd /var/www | #:: cd /var/www | ||
#:: chown -R apache:apache git | #:: chown -R apache:apache git |
Revision as of 08:51, 27 April 2015
<yambe:breadcrumb>Git</yambe:breadcrumb>
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 --shared
- git config --file config http.receivepack true
- 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 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>
Multiple machines can also be configured. Please refer to http://stackoverflow.com/questions/4575312/how-do-i-add-multiple-accounts-machine-login-password-to-my-vim-netrc-file
After this use 'git clone' or 'git push' as usual for configured server and git will automatically use above configured authentication. If permanent configuration is not desired then use git clone https://<username>@<server>/git/<repository> to make git prompt for password on command-line.
<yambe:breadcrumb>Git</yambe:breadcrumb>