On this page
What this issue is
Git is a version control tool. It keeps a hidden folder called .git inside a project. That folder holds every file, every past version and the commit history.
If someone deploys a site by running git clone or git pull straight into the public web folder (for example public_html or /var/www/html), the .git folder is published with the site. Anyone who requests https://yourdomain.com/.git/config can then read it. With a few more requests, tools can rebuild the whole repository.
Why it costs you leads or sales
This is a security leak rather than a conversion bug, but the damage reaches your funnel. Leaked database credentials or payment, email and CRM API keys can let an attacker read your leads, send mail as you, or change your checkout.
A compromised site can also be flagged by browsers or ad platforms, which can stop traffic and ad delivery. Your own code and logic are exposed too, which makes other flaws easier to find.
- Deploy by git pullRepository cloned into the web root
- .git is public/.git/config returns 200
- Secrets readKeys found in history
- Site or CRM abusedLeads stolen, mail or checkout altered
One public folder can end with a compromised funnel.
How to check if your site has it
Test only sites you own or manage. A safe result is a 404 (not found) or 403 (forbidden). Be wary of a 200 response or any file content.
Open the config file in a browser
Visit https://yourdomain.com/.git/config. If you see text such as [core] or [remote "origin"], the folder is exposed.
Check HEAD as well
Visit https://yourdomain.com/.git/HEAD. Content like ref: refs/heads/main confirms exposure.
Test with curl
Run the command below and read the status code. Repeat for each subdomain, staging site and old domain.
Beware of soft 404s
Some sites return a normal page with status 200 for missing URLs. Check that the body is real Git content, not your home page.
curl -s -o /dev/null -w "%{http_code}\n" https://yourdomain.com/.git/HEAD
curl -s https://yourdomain.com/.git/HEAD | head -n 1How to fix it
There are two parts: close the door now, then deal with anything that may already have leaked. The best fix is to stop publishing .git at all. Blocking it at the server is a second layer.
Block access immediately
Add a deny rule for dotted folders in your web server (see the tabs below). Re-test /.git/config.
Remove .git from the web root
Deploy built files only, or keep the repository one level above the public folder and point the web root at a subfolder. Deleting .git on the live server is fine if you keep the repository elsewhere.
Assume secrets leaked and rotate them
Change database passwords, API keys, SMTP logins, CMS salts and any tokens that were ever committed. Do this even if you see no sign of abuse.
Review logs and accounts
Look in server access logs for requests to /.git/ and check admin users, scheduled tasks and recent file changes for anything unfamiliar.
Stop committing secrets
Move secrets to environment variables or a secrets manager and add config files to .gitignore.
Delete the folder if it is in public_html
In your host's file manager or over SFTP, check the WordPress root (the folder with wp-config.php) for a .git folder. Remove it or move the repository outside the web root.
Add a rule for Apache hosts
Add the .htaccess rule shown below above the WordPress block. On Nginx hosts, ask your host or add the Nginx rule to the server config.
Apache: deny hidden Git paths
Add the .htaccess rule below, or put it in your virtual host config, then reload Apache.
Nginx: return 404 for .git
Add the location block below inside your server block, then run nginx -t and reload Nginx.
Change your deploy process
Build or export files into the web folder (for example with rsync or an artifact upload) instead of cloning into it.
Not usually affected
Shopify hosts the store, so you cannot publish a .git folder on the store domain. Check any separate server you use for apps, landing pages or a headless front end.
Not usually affected
Webflow hosting does not serve a .git folder. Check any other server or subdomain you run, such as a staging site or a self-hosted app.
RedirectMatch 404 /\.gitlocation ~ /\.git {
deny all;
return 404;
}How to confirm it's fixed
- /.git/config returns 404 or 403 on the main domain
- /.git/HEAD returns 404 or 403 too
- The same checks pass on www, staging and old subdomains
- Every secret that was in the repository history has been changed
- The old credentials no longer work
- Server logs show no further successful requests to /.git/
Exposed
- /.git/config returns 200
- Repository can be rebuilt from public files
- Old passwords still valid
Fixed
- /.git/ returns 404 or 403
- Repository sits outside the web root
- Secrets rotated and moved to environment variables
How to prevent it happening again
- Deploy built files, not a cloned repository
- Keep the web root separate from the project folder
- Keep the deny rule in your server config so a new deploy cannot undo it
- Never commit .env files, keys or passwords; use .gitignore and a secrets manager
- Run a secret scanner on your repositories
- Re-test /.git/config after every hosting move, new staging site or deploy change
How FunnelGuard handles this
FunnelGuard does not check for an exposed .git directory today. It is a possible future check.
What FunnelGuard does is run your real customer journeys, such as lead forms, checkouts and booking buttons, on a schedule. It checks each step, the tracking hits sent to ad and analytics platforms, and whether test leads reach your inbox and CRM. That can show you a funnel that breaks after a compromise, but it will not tell you a .git folder is public.
To watch for this yourself, add a recurring reminder to run the curl test above after each deploy, or use a vulnerability scanner or your host's security scan that tests for exposed Git folders. You can also run a free read-only FunnelGuard website audit, but do not rely on it for this issue.
Day 0
Site is deployed with git clone into the web root.
Day 1
Automated scanners request /.git/config and get a 200.
Day 2
The repository is downloaded, including an old API key in history.
Day 30
You find the folder, block it and rotate every key.
Questions people ask
How do I check if my .git folder is exposed?
Open https://yourdomain.com/.git/config in a browser, or run curl against /.git/HEAD. If you see Git text such as [core] or ref: refs/heads/main, the folder is public. A 404 or 403 means it is blocked.
Why is my .git directory visible on my website?
It is usually because the site was deployed by cloning or pulling a Git repository straight into the public web folder. The web server then serves the hidden .git folder like any other directory unless a rule blocks it.
What can an attacker do with an exposed .git folder?
They can download your source code and full commit history, then search it for passwords, API keys and database details. They can also study your code for other weaknesses to attack.
How do I block the .git folder in Nginx or Apache?
In Nginx, add location ~ /\.git { deny all; return 404; } to your server block and reload. In Apache, add RedirectMatch 404 /\.git to .htaccess or the virtual host. Then re-test /.git/config.
Is it enough to delete the .git folder from my server?
Deleting it stops further downloads, but it does not undo any copy already taken. You should also rotate every password, key and token that was ever committed to the repository.
Do Shopify or Webflow sites have an exposed .git directory?
Usually not, because those platforms host the site and do not serve a .git folder. Check any separate server you run, such as staging, a headless front end or a custom app.
Does FunnelGuard detect an exposed .git directory?
No. FunnelGuard does not check for this today, though it is a possible future check. It monitors your funnel journeys, tracking hits and lead delivery, so use a security scanner or a manual curl test for .git.