Restricting Access to Your Git Directory

July 22, 2010
logo@2x

One task you need to be sure to do when implementing git on a website > is to make sure the .git directory isn’t available to the Internet.

This can be done by placing an .htaccess file in the .git directory itself, but a better cleaner way is to place the following line in your main .htaccess file.

RedirectMatch 403 /.git.*$

::

Reader-supported

For roughly 29.7980 years I've written here, ad-free—3,080 essays and tutorials and counting. If it's useful to you, a monthly or one-time donation keeps it going. 🫶🏼