Skip to content

Instantly share code, notes, and snippets.

@anytizer
Created October 13, 2024 17:15
Show Gist options
  • Save anytizer/47155589b91399c82f0e676adf549d89 to your computer and use it in GitHub Desktop.
Save anytizer/47155589b91399c82f0e676adf549d89 to your computer and use it in GitHub Desktop.
GIT over HTTP(s) DAV - Reference
# Creating a git Repo over HTTP(s)
It could be riskier to use git over http(s).
Use alternatives when possible.
Reference materials
- https://git-scm.com/docs/git-update-server-info.html
- https://git-scm.com/book/en/v2/Git-on-the-Server-Smart-HTTP
- https://web.mit.edu/git/www/howto/setup-git-server-over-http.html
```
# sudo apt install litmus
# sudo a2enmod dav_fs
# sudo a2enmod dav
# USERNAME=<YOUR_APACHE_USERNAME> # www-data
# sudo mkdir -p /var/www/git-http/<PROJECT>.git
# cd /var/www/git-http/<PROJECT>.git/
# sudo git init --bare .
# git update-server-info
# sudo chgrp -R $USERNAME /var/www/git-http/
# sudo chown -R $USERNAME:$USERNAME /var/www/git-http/
# sudo touch /etc/apache2/passwd.git
# sudo chown -R $USERNAME:$USERNAME /etc/apache2/passwd.git
# sudo -u $USERNAME htpasswd -c /etc/apache2/passwd.git <AUTH_USER>
# sudo chown $USERNAME:$USERNAME /var/lock/apache2/DAVLock
# sudo nano /etc/apache2/sites-available/002-git.conf
# ==============================================
<IfModule mod_dav_fs.c>
DavLockDB "/var/lock/apache2/DAVLock"
DavLockDiscovery off
DAVMinTimeout 600
<Directory /var/www/git-http>
Options +Indexes +FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Alias "/git-http/" "/var/www/git-http/"
<Location "/git-http/">
Dav On
AuthType Basic
AuthName "Restricted GIT Repository"
AuthUserFile /etc/apache2/passwd.git
<Limitexcept GET HEAD PROPFIND OPTIONS REPORT>
Require valid-user
</Limitexcept>
</Location>
</IfModule>
# ==============================================
# sudo apachectl restart
# sudo tail -f /var/log/apache2/error.log
# sudo tail -f /var/log/apache2/access.log
litmus http://<IP>/git-http/<PROJECT>.git/ <USERNAME> <PASSWORD>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment