The problem in one sentence
If your website deploys by copying a git repository onto the server and the .git folder is reachable over the web, anyone can download your entire source code and its full history.
Why it is worse than it sounds
The .git folder contains every version of every file ever committed. That often includes:
- API keys or passwords that were committed once and "removed" later
- old configuration files and database credentials
- admin routes and hidden endpoints
- the exact code, which makes finding other vulnerabilities far easier
Freely available tools can rebuild a full repository from an exposed .git folder in minutes, even when directory listing is switched off.
How to check your site
Try these in a private browser window:
https://yourdomain/.git/confighttps://yourdomain/.git/HEAD
If either returns text (rather than 403 or 404), your repository is exposed. A free scan checks this automatically, along with exposed .env files and backups.
How to fix it
- Block dotfiles at the web server. Deny every path starting with
/.except/.well-known/, which is needed for certificates and security.txt. - Deploy build output, not the repository. Use a CI pipeline or deploy tool that copies only the files the site needs.
- Delete the folder from the server if it is not needed there.
If it was exposed
Treat it as a leak of everything in the history.
- rotate every secret that has ever been committed, even if later deleted
- review the code for vulnerabilities an attacker now knows about
- check server and application logs for unusual access
- in future, use a secret scanner in CI to stop secrets being committed at all
Our API key security guide covers rotation and storage.
Related exposures to check
/.svn/and/.hg/for older version-control systems.DS_Storefiles that reveal folder contentsbackup.zip,site.tar.gzand.sqldumps in public folders- directory listing switched on — see directory traversal
Make it part of every scan
Exposure checks take seconds and catch some of the most damaging mistakes. Yrzo AI includes them in every report — see plans.
Related reading: Exposed .env Files: Why They Are Dangerous and How to Check Yours · What Is Attack Surface Management? A Plain-English Guide · security.txt Explained: How to Add One to Your Website