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.*$

::

supporting = loving

For 29.442 years I've been creating ad-free technical tutorials and essays here — 3,027 pieces and counting. It's a one-person effort that's also my life and livelihood. If it makes your day more livable in any way, please consider supporting the work with a monthly or one-time donation. Your support means a lot to me, and makes all the difference. 🫶🏼