Which GitHub Account Is Git Using? 4 Checks Before You Push
To see which GitHub account git is using, check four separate things: the commit email (git config --show-origin user.email), the SSH key (ssh -T git@github.com), the GitHub CLI session (gh auth status) and commit signing (git log -1 --show-signature). They are configured independently, and they can disagree.
That is why “which account am I?” has no single answer. Here is how to ask each layer, and what to do when the answers don’t match.
Which GitHub account is git using to push?
The push is authenticated by the transport, not by your commit email. Start with the remote:
git remote -v
git@github.com:acme-inc/billing.gitmeans SSH. The key decides who you are.https://github.com/acme-inc/billing.gitmeans HTTPS. The stored credential (credential helper orgh) decides who you are.
For SSH, ask GitHub directly:
ssh -T git@github.com
# Hi your-username! You've successfully authenticated, but GitHub does not provide shell access.
The name in that greeting is the account that owns the key SSH offered. If you use host aliases such as github-acme, test the alias, not the bare host: ssh -T git@github-acme. The exit code is 1 even on success, so don’t treat that as an error.
To see which key SSH would offer without connecting, print the resolved config:
ssh -G github.com | grep -i -E 'identityfile|identitiesonly'
If IdentitiesOnly is not yes, your agent may offer keys in an order you did not choose. We cover that trap in multiple SSH keys for GitHub and IdentitiesOnly.
Which email will my commits carry?
Ask git for the value and where it came from:
git config --show-origin --get user.email
git var GIT_AUTHOR_IDENT
--show-origin tells you whether the email comes from ~/.gitconfig, a repo’s .git/config or an includeIf file. git var GIT_AUTHOR_IDENT prints the full author line git will actually write, including environment overrides such as GIT_AUTHOR_EMAIL.
If the value is wrong inside a client folder, your includeIf rule probably didn’t match. See git includeIf: different email per folder for the usual traps (trailing slash, gitdir versus gitdir/i, rule order).
Already committed with the wrong one? The fix is in fix a wrong email in git commits.
Which account is the GitHub CLI using?
gh auth status
This lists every account gh knows for each host and marks the active one. Pull requests, issues and gh repo clone use that active account. Change it with gh auth switch. The catch is that this only moves the CLI, not your email or your SSH key: see what gh auth switch misses.
Are my commits signed with the right key?
git config --get commit.gpgsign
git config --get user.signingkey
git log -1 --show-signature
If the signing key or the committer email does not belong to the account that pushed, GitHub shows a gray “Unverified” badge. The details are in unverified commits with multiple accounts.
A four-line check you can paste
git remote get-url origin
ssh -T git@github.com
git var GIT_AUTHOR_IDENT
gh auth status
Run it from inside the repo, since the answers change with the folder. If the SSH greeting says one account and the author line says another, you are about to push client work under the wrong identity. Better to find out now than in a code review.
Why checking by hand doesn’t scale
Four commands are fine once. They are not fine at 6:45 p.m. before a hotfix, in a fresh clone under /tmp, where no folder rule applies. The failure is quiet: the push often succeeds, just as the wrong person.
Hats is a macOS menu bar app that keeps these layers aligned. It binds a folder to a profile, so email, SSH key, gh session and signing switch together, and its guard blocks the commit or push when the hat doesn’t match the folder. hats status prints the verdict for the current repo. It is free for two profiles: brew install --cask xorbeta/hats/hats.
FAQ
Does git config user.email tell me which GitHub account I’m logged in as?
No. It only sets the author email on new commits. GitHub links commits to an account by email address, but your push is authenticated separately by your SSH key or HTTPS credential.
Why does ssh -T git@github.com show the wrong username?
SSH offered a key that belongs to a different account, usually the first key in your agent or the default id_ed25519. Set IdentitiesOnly yes and an explicit IdentityFile for each host alias, then test the alias.
Can I push as one account and commit as another?
Yes, and it happens by accident all the time. The push uses your key or token, while the commit carries whatever email git had configured. GitHub accepts both and attributes the commits by email.
How do I check this for a repo I just cloned?
Run the four-line check from inside the clone. Cloning over an SSH alias or into a folder covered by an includeIf rule usually gives the right result; a clone into an unrelated folder falls back to your global config.
Is there a GitHub page that shows which key I pushed with?
Not for a past push. You can see which keys are registered under Settings, SSH and GPG keys, but the most reliable check is the one you run before pushing.