README.md

Git good

Git good makes sure your commits are saved under the right name and email.

Git stamps every commit with a name and email from its config. It doesn't care which account you're signed in with on GitHub, GitLab or Git Cafe. When nothing is set, Git guesses from your computer, and coding agents often fill the gap with a wrong or outdated address. Git good saves the identity you want once, stops Git from guessing, and tells you when a repo would commit under anything else.

Install

You need Bun and Git.

sh
1git clone <this repo> git-good
2cd git-good
3bun install
4bun install -g .

This puts git-good in Bun's global bin folder (~/.bun/bin, or %USERPROFILE%\.bun\bin on Windows). If Bun warns that the folder isn't on your PATH, add it.

Prefer a single file? bun run build creates dist/git-good (dist\git-good.exe on Windows). Copy it to any folder on your PATH.

Because the command starts with git-, Git also runs it as git good.

Use

git good setup

Asks for your name and email and saves them as your profile. The profile lives in your config folder, not in any repo:

  • Windows: %APPDATA%\git-good\profile.json
  • macOS: ~/Library/Application Support/git-good/profile.json
  • Linux: ~/.config/git-good/profile.json

It also sets user.useConfigOnly = true in your global Git config, so Git refuses to commit instead of guessing. It sets your global user.name and user.email only if you say yes. You see every change before anything is written.

To skip the questions: git good setup --name "Your Name" --email you@example.com --no-global --yes.

git good check

Run it inside a repo. It asks Git which name and email the next commit will use, for both the author and the committer. That covers the repo's own config, your global config, git -c flags and the GIT_AUTHOR_* / GIT_COMMITTER_* environment variables. Then it compares the result with your profile.

When something is wrong, it says where the wrong value came from and how to fix it:

1Profile screen <screen@users.noreply.git.cafe>
2
3✓ author screen <screen@users.noreply.git.cafe>
4✗ committer screen <agent@example.com>
5
6 committer email: environment variable GIT_COMMITTER_EMAIL
7
8Git will commit under the wrong identity.
9→ Remove the environment variable GIT_COMMITTER_EMAIL. A shell profile, terminal or agent app set it.

Exit codes: 0 match, 1 mismatch, 2 no identity, 3 no profile saved, 4 error.

Add --json to get the same result as JSON, for scripts, agent launchers and other apps. Add --quiet to print nothing when everything matches.

git good fix

Writes your profile into the current repo's own config (user.name and user.email), shows the before and after, and changes nothing else. If something still overrides it, such as an environment variable, it tells you what.

git good hook install

Adds a pre-commit hook to the current repo, so a commit under the wrong identity stops before it's made. It never replaces an existing hook. If one exists, it shows the line to add yourself.

The hook is a plain sh script. Git for Windows ships its own sh and runs hooks with it, so you don't need Bash installed.

Help

Run git good help or git-good --help. (git good --help makes Git look for a manual page instead.)

Develop

sh
1bun install
2bun test
3bun run typecheck
4bun src/cli.ts check

Set GIT_GOOD_CONFIG_DIR to keep test runs away from your real profile.

License

MIT