Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

git-whoami

Shows your effective git identity and SSH key for the current directory.

Works both inside and outside git repositories. Outside a repo, it resolves your ~/.gitconfig includeIf rules against the current directory to show what identity and SSH key would be used when cloning here.

Example output

Inside a repository:

=== Git Configuration Analysis ===
Working directory: /home/user/git/github.com/work-org/project
Git repository: /home/user/git/github.com/work-org/project

--- Git User Configuration ---
Name:  Your Professional Name
  Source: file:/home/user/.gitconfigs/work.gitconfig
Email: you@company.com
  Source: file:/home/user/.gitconfigs/work.gitconfig
SSH Command: ssh -i ~/.ssh/id_work
  Source: file:/home/user/.gitconfigs/work.gitconfig

--- Git Remote Configuration ---
Remote 'origin': git@github.com:work-org/project.git
  Host: github.com
...

Outside a repository (before cloning):

=== Git Configuration Analysis ===
Working directory: /home/user/git/github.com/work-org
Git repository: Not a git repository (showing config that would apply here)

--- Effective Git Identity ---
Name:  Your Professional Name
  Source: file:/home/user/.gitconfigs/work.gitconfig
Email: you@company.com
  Source: file:/home/user/.gitconfigs/work.gitconfig
SSH Command: ssh -i ~/.ssh/id_work
  Source: file:/home/user/.gitconfigs/work.gitconfig

--- Config Resolution ---
~/.gitconfig
  user.name = Your Name
  user.email = your-default@email.com
includeIf "gitdir:~/git/github.com/" -> ~/.gitconfigs/work.gitconfig
  user.name = Your Professional Name
  user.email = you@company.com
  core.sshCommand = ssh -i ~/.ssh/id_work

--- SSH Key ---
Key: /home/user/.ssh/id_work
  256 SHA256:xxxx (ED25519)
ℹ️  SSH host authentication depends on which remote you clone from
ℹ️  Run git whoami inside a cloned repository for full SSH host analysis

Installation

# Clone or download git_whoami.py, then link it into your PATH
ln -s /path/to/git_whoami.py ~/.local/bin/git-whoami
chmod +x /path/to/git_whoami.py

git automatically finds commands named git-<command> in your PATH, so after installation git whoami works from any directory.

Requirements

  • Python 3.10+
  • git
  • ssh, ssh-keygen (standard OpenSSH tools)

Related

This tool pairs with the scalable-git-ssh-config guide for directory-based git identity and SSH key management.

About

Show effective git identity and SSH key for the current directory

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages