Files
dotfiles/docs/git-auth.md
T

5.9 KiB

Git identity and authentication

Profile Commit email SourceGit HTTPS credential storage Sign-in
full anonymous0programmer@gmail.com (owner-confirmed GitHub email) Installed Desktop Secret Service/keyring Browser OAuth or unlocked Bitwarden
full-work ziad.arafat@etvamerica.com Installed Desktop Secret Service/keyring Browser OAuth or unlocked Bitwarden
headless / headless-aarch64 Personal email Omitted One-hour memory cache Terminal personal-access token or unlocked Bitwarden

Commit identity follows the selected dotfiles profile. A repository-local user.email still overrides the default using normal Git precedence. HTTPS credentials are selected independently by the remote's host; a work token is not sent to a personal host. SSH remotes continue using SSH keys and do not invoke HTTPS credential helpers.

Desktop use

After dot switch, open SourceGit from the application launcher or run sourcegit. It uses the configured Git credential helper. On the first private HTTPS fetch/push, the browser opens for GitHub or the matching Gitea instance:

Sign in normally, including SSO/MFA, and approve the Git OAuth application. Public repository reads may succeed without a login, which is normal. Stock Gitea instances provide the OAuth application used by git-credential-oauth; instances where that application has been disabled need it enabled by their administrator. This dotfiles change does not modify either server.

The helper checks an explicitly unlocked Bitwarden context, then the desktop credential manager's saved entry, then starts OAuth if needed. Successful OAuth credentials are saved through Git Credential Manager's Secret Service backend. The desktop profile provides the GNOME Keyring secrets user service; an existing Secret Service provider can also be used. The keyring must be unlocked in the desktop session (it may prompt for its own password). Vault lookup does not automatically insert OAuth credentials into Bitwarden.

Headless use

The helper uses terminal prompts, with GCM GUI prompts disabled. Enter the appropriate GitHub/Gitea username and a personal access token when requested; tokens need repository permissions appropriate to your operation. Headless does not launch OAuth browser callbacks or a GUI. Accepted credentials are cached in memory for one hour and are lost at cache expiry or reboot.

For unattended use, unlock the appropriate Bitwarden context in the process environment or provide an explicit automation credential helper. The interactive prompt is not a replacement for a CI credential source. No token is committed.

Optional Bitwarden credentials

git-vault wraps the existing Bitwarden CLI with isolated per-vault app-data directories. It configures only that context's expected server, and refuses to switch it while logged into a different server. It does not change the general bw CLI or dot secrets account.

Remote Vault context / server Environment containing its unlocked session
gitea.etvamerica.com work / https://vault.etvamerica.com BW_SESSION_WORK
gitea.godemperordoge.org personal / https://vault.godemperordoge.org BW_SESSION_PERSONAL
github.com work for full-work, personal otherwise Corresponding variable above

Log in once to the selected context and capture the unlock session without printing it. For example, for the personal SSO vault:

git-vault personal login --sso
export BW_SESSION_PERSONAL="$(git-vault personal unlock --raw)"
git-vault personal sync

For the work vault, use git-vault work login with your normal login method and export BW_SESSION_WORK="$(git-vault work unlock --raw)". On headless systems, git-vault personal login --apikey is an option where supported by your vault; enter the client credentials at its prompts rather than in command arguments. Existing SSO/vault enrollment and master-password requirements still apply.

Create a Login item named exactly Git: <host> (for example, Git: github.com) with:

  • URI https://<host>
  • Your Git username
  • A repository-scoped personal access token in the password field

The helper uses only that named item and an exact HTTPS hostname match, not your ordinary website-password item. Username hints must also match. Deleted or ambiguous matching items are ignored, and credentials from the wrong vault server are never returned. Vault sessions are inherited from the calling process; start sourcegit from the unlocked terminal if you want it to use that session. The normal desktop browser/keyring flow works without these session variables.

The helper reads unlocked vault entries but does not modify them. If a stored PAT has been revoked, update/remove that item in Bitwarden before retrying. Use unset BW_SESSION_PERSONAL BW_SESSION_WORK when finished with the shell session. Do not run credential lookup with tracing or print its protocol output: it contains a password/token intended only for Git.

Migration and checks

dot secrets render no longer writes ~/.git-credentials, and Git no longer configures credential.helper=store. An existing file is left untouched and is not read by the new helper; remove/archive it yourself after checking whether other tooling still needs it. Existing machine-local repository overrides can still replace the generated helper.

Apply with git pull and dot switch on the target machine. Check the selected email with git config user.email. Run bash tests/profiles.sh to evaluate the profile boundaries. The Go helper has offline fixture tests for host/vault isolation, locked/wrong vaults, ambiguous entries, desktop OAuth fallback, headless browser avoidance and credential persistence routing.

References: