# From an exposed /.git/config to your whole repository
*articles*
Leave .git in what you deploy and /.git/config reveals the remote URL, with the whole history possibly downloadable. Here is how V11 in vuln (Priority 3) sees it and how to keep it out.


Have you ever opened `/.git/config` by adding it after your site's URL? If a check flagged ".git/config exposure", this article covers what it reveals and how to stop it.

The short answer: **if .git is not in what you publish, this finding cannot happen**. If `/.git/config` can be read, the repository (where the source code and its history are kept) may be downloadable from the same place. Secrets you deleted along the way are still in that history.

## .git is the notebook where your work is recorded

Imagine leaving the notebook where your work is recorded on a shelf anyone can open. The cover lists who owns it and where it is kept, and opening it lets people read past pages. .git is that notebook.

.git is the folder Git (the system that records changes to your files) creates at the top of a project. It records who changed what and when, the contents of past files, and settings.

Inside it, config is close to the notebook's cover page. It records the URL of the remote repository (where the code is kept), the name of the branch you are tracking (a line of work), and fetch settings. If you use Git, most projects have one automatically.

Git's official documentation is here.

- [git-config official documentation (English)](https://git-scm.com/docs/git-config)
- [Pro Git: Git Internals (English)](https://git-scm.com/book/en/v2/Git-Internals-Plumbing-and-Porcelain)

## What config reveals

On its own, config does not let anyone read your code. It does reveal the following.

- The remote repository URL (host name and repository name)
- Which branch you are tracking
- A username or token if one is embedded in that URL
- The simple fact that this site has a .git folder behind it

**The last one is the real problem.** Once someone knows .git exists, they know where to look next. Git stores history as "objects" under .git/objects. If those URLs can be built and fetched one by one, past files can be reconstructed.

So a readable config is not the end of the damage. **Assume the whole repository and its history were read.** History often still contains API keys (strings used to call external services) and passwords that were removed later.

## Why it ends up in the public folder

`.git` shows up in public for the same kind of reason as `.env`: it was put in the wrong place. There are a few common routes.

- The whole project folder was uploaded by FTP (a way to send files to a server) or drag and drop
- The project was cloned with `git clone` on the server and served from that folder
- The build (turning the project into a publishable form) wrote its output into the project root, so .git was published along with it
- The entire project was placed in a static host's public directory

Folders starting with `.` are hidden in your computer's file list. On the web they are not hidden. If the name is requested, the files are served.

This is easy to confuse with .gitignore. .gitignore tells Git "do not record this file". It does not keep files off your server. **Keeping files out of what you publish is a setting on the hosting side.**

## What vuln shows

In vuln (a [free check that only needs the URL of your live site](/en/vuln)), .git/config appears as one line under V11.

- V11 .git/config exposure (area: Exposure, priority 3)

The scope is fixed.

- Fetch `/.git/config` (first 64KB)
- Require HTTP 200 or 206, a Content-Type (the kind of content returned) that is not text/html, and a body that does not start like HTML
- Require both `[core]` and `repositoryformatversion` in the body
- If they match, the result is Needs work

The evidence shows the URL that was fetched and the HTTP status. The contents of the remote URL are not shown.

A 404 (page not found) or 403 (refused) is a pass. If the request could not be made, the item is not checked.

**A pass means "not found at /.git/config"**. It does not mean .git/HEAD or .git/objects were also checked. It is worth confirming those yourself.

The official references are below.

- [OWASP Web Security Testing Guide (English)](https://owasp.org/www-project-web-security-testing-guide/)
- [CWE-538 description (English)](https://cwe.mitre.org/data/definitions/538.html)

## Measured: this site

On November 28, 2026, I fetched four paths with curl (a command that downloads the contents of a URL). They were `/.git/config`, `/.git/HEAD`, `/.git/` and `/.gitignore` on `https://ismyappok.com`.

All four returned **HTTP 404**, with a `text/html` "Page Not Found" page (77,764 bytes). No .git is served, so V11 is a pass.

This site runs on Cloudflare and serves static files as Workers assets. Because .git is not in what we deploy, the request returns 404.

Cloudflare's official documentation is here.

- [Cloudflare Workers static assets documentation (English)](https://developers.cloudflare.com/workers/static-assets/)

## How to fix it

First, keep .git out of what you publish. Make sure .git does not end up in the output folder (`dist`, `public`, `out`).

If your host builds from the Git repository, your local .git is not part of what gets published. If you upload by FTP, remove .git before you upload.

If you do not know what your site is published from, look for the "Publish Directory" setting in the tool you use. Tools that publish on your behalf only publish the build output, so this finding usually does not happen there.

Second, block it on the hosting side. Add a rule that returns 404 or 403 for paths starting with `/.git/`. Some hosts have a setting in the dashboard; others need a rule in the server or CDN configuration in front of your site.

Third, and most important, assume the history was read if .git was ever public. **Recreate every secret that was in the repository, treating it as leaked.** The order is database passwords, payment and email API keys, then the key that signs logins.

Also check these three things.

- Whether the delivery logs show requests to `/.git/` (one request is enough to assume it was downloaded)
- Whether the remote URL contained a token (a short string used instead of a password); if so, revoke that token
- Whether the database or payment service shows activity you do not recognise

If you cannot see the logs, do not treat that as a clean result. Assume it was taken and proceed.

Removing secrets from history can wait. If they were already taken, rewriting history does not undo that. **Recreate them first and invalidate the old values.**

## Wrapping up

Start by opening `https://your-domain/.git/config` in a browser. A "page not found" screen, or your usual HTML page, means today's work is done.

If you see text with `[core]` and `repositoryformatversion`, close it and recreate the secrets that were in the repository.

.git is the notebook where your work is recorded. It does not belong on a public shelf.

Once the notebook is out, even the pages you removed can be read. Moving it out of the way is all it takes to clear this finding.

This check only takes adding one path to your URL, so it is worth doing every time you publish, I think.

The fix for each item is collected here.

- [.git exposure](/en/checks/git-config-exposure)
- [.env file exposure](/en/checks/env-file-exposure)
- [Secrets in client-side JavaScript](/en/checks/client-secrets)

Related articles.

- [What happens when .env is open to the world](/en/articles/env-file-exposure)
- [What a public source map gives away](/en/articles/source-map-exposure)

When you have reviewed the settings, [run a vuln check](/en/vuln). You can also check your public pages and links before launch with [audit (a free service for checking pages and links before launch, no login required)](/en/audit).

This article was written by checking our own site. It does not include results from scanning anyone else's site. Numbers quoted here are the check's implementation conditions. Measured values appear only with the date and method noted above.

## Check your own site
Enter a URL and see what is missing before launch. Free, and no login required.
[Run the free check](https://ismyappok.com/en/audit)