Skip to main content

Git And Identity

This setup is built around the idea that:

  • private keys should not live on disk
  • git identity should switch automatically based on where you're working

The mechanics are implemented through a combination of 1Password's SSH agent, ~/.ssh/config, and git's includeIf support.

SSH Agent

SSH is wired to use the 1Password agent socket:

The 1Password agent key set is configured via:

Installed as:

  • ~/.ssh/config

Public Keys On Disk

Git is configured to use SSH "public key" paths as identity selectors. The matching private keys are held by 1Password.

Relevant templates:

Git Config

Primary git config:

Installed as:

  • ~/.gitconfig

Work override (included conditionally):

The primary config uses includeIf "gitdir:~/work/" on non-work machines so repos under ~/work/ automatically use the secondary identity.

GitHub CLI + GitHub Picker

ComponentSource
GitHub CLI config directoryhome/dot_config/exact_private_gh/ (private)
gh picker work confighome/dot_config/exact_tmux/exact_scripts/pickers/github/readonly_gh-picker-work.yml
gh picker home confighome/dot_config/exact_tmux/exact_scripts/pickers/github/readonly_gh-picker-home.yml
Managed extensions hookhome/.chezmoiscripts/run_onchange_after_05-install-gh-extensions.fish.tmpl

Git TUIs:

ToolConfig
gituihome/dot_config/exact_gitui/
lazygithome/dot_config/exact_lazygit/config.yml
tighome/dot_config/exact_tig/

Signing

Git commit signing is configured for SSH signing, using the 1Password signing helper:

Verify

See which identity is currently active:

git config --get user.name
git config --get user.email
git config --get core.sshCommand

If you are in a repo under ~/work/ on a non-work machine, you should see the secondary identity.

Troubleshooting

  • Identity did not switch:
    • verify repo path (~/work/... for includeIf-based work identity on non-work machines).
    • check effective config origin:
git config --show-origin --get user.email
git config --show-origin --get core.sshCommand
  • SSH auth problems:
    • verify SSH_AUTH_SOCK points to 1Password agent socket.
    • verify required key is enabled in 1Password agent config.