AppInspected

Fix guides

Your .git folder can be downloaded from your website.

Last reviewed November 30, 2026 against the providers' current documentation.

The short version

Treat every secret that was ever committed as leaked and rotate it first, including any token saved in your Git remote URL. Then remove the .git folder from what you deploy and block requests for hidden paths at your server. Deleting the folder stops new downloads, but it doesn't take back copies.

Why it matters

The .git folder is your whole repository: Git's docs describe objects/ as the repository's "object store" and config as the "repository specific configuration file". If a web server publishes it, the files can be fetched one by one and reassembled into your complete source code, including old commits. Any API key, password or .env file that was ever committed comes along, even if you deleted it later. Turning off directory listing doesn't help, because the files inside .git follow a fixed layout and can be requested by name.

Fix it, in this order

  1. Check it yourself

    Open https://yoursite.com/.git/HEAD in a private window. Git's docs describe HEAD as a pointer to the current branch, so it usually holds one line like ref: refs/heads/main; in a "detached HEAD" state it holds a commit hash (40 hex characters) instead. Either one means the folder is exposed. Also try /.git/config. If you see your normal homepage or a 404, it isn't exposed.
  2. Rotate every secret in the history, first

    Assume the whole history was copied. Search it for keys (git log -p or a secret scanner), and rotate each one in the provider's dashboard, starting with payment, database and AI keys (see Stripe, database URL, OpenAI). Then open .git/config on the server: git clone saves the address you cloned from as remote.origin.url, so if you cloned with a token in the URL (https://TOKEN@github.com/...), that token is in the exposed file. GitHub says to treat access tokens "like passwords"; revoke it (see GitHub token exposed). GitHub's guidance is that revoking or rotating comes first.
  3. Stop deploying it

    This happens when the folder your host publishes is the project root rather than a build folder. Point your host at the build output (dist/, build/, out/), or, for a plain static site, deploy with a command that copies files without .git. If you git clone or git pull straight into the web root on a server, move the checkout outside it and copy only the site files in. Firebase Hosting's default firebase.json already ignores dotfiles with "**/.*"; keep that line.
  4. Block dotfiles at the server

    As a safety net, refuse requests for hidden paths, except /.well-known/ (used for HTTPS certificates and other standard files). On nginx:
    location ~ /\.(?!well-known) {
        deny all;
    }
    On Apache (in the site config or .htaccess), a status outside 300-399 takes no target URL:
    RedirectMatch 404 /\.(git|env)
    Reload the server and open /.git/HEAD again: you want a 403 or 404.
  5. Decide whether to rewrite history

    Only after rotating. GitHub says rewriting history to remove a rotated secret "may not be warranted", and that the old commits can stay reachable in clones, forks and cached views anyway. If you do need it (for example, the history holds personal data rather than a key), GitHub documents git-filter-repo --sensitive-data-removal, which needs git-filter-repo 2.47 or later, and lists the side effects for everyone working on the repository.

Or ask your AI tool to do it

Paste this into Lovable, Bolt, Cursor, Claude Code or whichever tool built your app. Review what it changes before you deploy.

My website is serving the .git folder (yoursite.com/.git/HEAD loads). 1) Change the deployment so only the build output folder is published and no dotfiles (.git, .env) are ever included; if the site is a git checkout inside the web root, move it out. 2) Add a server or host rule that returns 404 or 403 for any path starting with a dot, except /.well-known/. 3) Check .git/config for a remote URL with a token or password in it. 4) Search the full git history for API keys, tokens, passwords and .env files, and give me a list of every secret I need to rotate, with the provider for each. Don't print the secret values.

How this happens

It's common on simple hosting: you clone the repository onto a server and point the web server at that folder, or you upload the whole project directory, or a static host publishes the project root instead of the build folder. The .git folder is hidden in most file browsers, so nobody notices it went along.

Check that it's really fixed

After you deploy, run the free check. It reads your live site the way an attacker would and tells you if any secret key is still visible.

Topic check: Website security check

Find the other leaks before someone else does

The free check reads your home page and its scripts. The website security report goes through up to 30 pages and 40 JavaScript files, plus .env and .git files, security headers, cookies and CORS, domain and email records, and libraries with known vulnerabilities. Every finding comes with the fix for your host and a prompt for your AI tool.

$19 once, including 20 runs over 30 days so you can fix things and check again.

Get the report, $19 See an example report

Example report header: a score out of 100, findings by severity, Download PDF and Email me this report.

Questions

My repository is public on GitHub anyway. Does this matter?

Less, because your code is already public. But check .git/config on the server for a token in the remote URL, check whether the deployed copy includes commits or files that aren't on GitHub, and still rotate any secret that was ever committed.

I deleted the folder. Am I safe?

Not if it was reachable before. Treat every secret in its history, and any token in its config, as leaked and rotate it.

Directory listing is off and /.git/ shows 403. Is that enough?

No. The files inside .git have fixed names (HEAD, config, refs/heads/..., objects/...), so they can be requested directly without a listing. Test /.git/HEAD, not /.git/.

Do I have to rewrite my git history?

Usually not. Rotating the secret makes the old value useless, and GitHub says rewriting "may not be warranted" once that's done. Rewriting is for cases like personal data in the history, and it can't reach copies others already made.

How does the AppInspected check find it?

The free check requests /.git/HEAD on your site and flags it when the response starts with ref: refs/. It doesn't download anything else from the folder. A detached HEAD (a bare commit hash) isn't flagged, so if you deploy that way, open /.git/HEAD yourself. The check also requests /.env and coding-agent files such as /.claude/settings.local.json.

Sources

Related guides