Skip to content
Kruno Golubić
Go back

Where Did Git Find My Email Address?

Kruno Golubić

Setting up a new machine is one of those things you do infrequently enough that some steps slip through. The first time I pushed from a freshly set up machine, git warned me my identity was not configured. Fair enough. But below the warning was something I did not expect: a commit attributed to kgolubic@example.com.

I had never typed that address anywhere.

Git did not find it. It constructed it.

When there is no user.email set in your git config, git falls back to building an identity from whatever it can scrape from the environment. On a Windows machine, that means taking your Windows login name and combining it with your machine’s hostname. In my case: kgolubic + example.com = kgolubic@example.com. A perfectly plausible-looking email address that belongs to no inbox anywhere.

The warning actually tells you what happened, in plain text: “Your name and email address were configured automatically based on your username and hostname.” Most people dismiss it and move on. The fabricated address then travels into commit history, and if you push to a public repository, it sits there permanently.

The fix is two lines:

git config --global user.email "you@yourdomain.com"
git config --global user.name "Your Name"

The --global flag writes to ~/.gitconfig and applies across all repositories on that machine. If you need a different identity for a specific project, say a work repo with a company email, run the same commands without --global inside that repo’s directory. The local setting takes precedence over the global one.

One thing worth knowing: changing the config does not rewrite history. Commits that already went out with the fabricated address stay exactly as they are. Git bakes the author identity into the commit hash at the moment of commit, and changing it after the fact means a history rewrite. Not worth doing unless the repository is private and you have a strong reason to care.

Verify the current config with:

git config --global --list

Set it once on each new machine and you will not think about it again. The warning is git’s way of telling you it had to improvise.


Share this post on:

Previous Post
Speaking at DORS/CLUC 2026
Next Post
Why Are There So Many Dead Posts on Hacker News