Exposed .git folder

Why a public .git folder can hand over your site source code and history, how the scan spots it, and how to block access and clean up.

What AuditX checks

The scan requests /.git/config at the root of your site and reads the start of the response. It fails when the server answers with a success status (2xx) and the text contains repositoryformatversion or a [core] section, which is what a real git config file looks like. Anything else passes, including a redirect, which the scan does not follow. If the request never completes, the check is shown as not measured and is left out of the score. It reads that one file only: it does not try to download the repository or look for other version-control folders.

Why it matters

The .git folder holds the full history of your code. If the web server publishes it, a visitor can often rebuild the whole project from it, including old versions of files that once contained passwords.

Source code shows an attacker how your site works, and secrets committed at any point in the past stay in the history even if you deleted them later.

How to fix it

  1. Deploy only the built files to the web root, not the whole git working folder. A deploy tool or an export of the files is safer than cloning the repository into the web root.
  2. If the folder has to be there, add a server rule that denies any request that starts with /.git.
  3. Check by opening yourdomain.com/.git/config: you should get an error, not text.
  4. Assume any password, key or token that was ever committed is exposed. Rotate each one, because deleting the file from the repository does not remove it from the history.
# nginx
location ~ /\.git {
    deny all;
}

Does your site pass this check? A free scan runs it with every other check and shows the result in about a minute.

Scan my site

Sources

Related checks

Last reviewed 2026-11-13.