Skip to content

Latest commit

 

History

History
12 lines (10 loc) · 3.53 KB

git.md

File metadata and controls

12 lines (10 loc) · 3.53 KB

Git config

Shared and host-local Git settings, identities and credentials.

  • ~/.gitconfig → symlink into the repo, identical on all hosts. git config --global alias.x ... lands there directly → commit, done.
  • ~/.gitconfig.local → host-local, not in git, included after the shared settings. machine setup creates it once from the context (work → work user, otherwise private) and never overwrites it; on work hosts an existing file only gets a missing http.sslCAInfo appended. Signing key, safe.directory, credentials and proxy go here.
  • Owner rules at the end of ~/.gitconfig override the host default by remote URL: github.com bosch-*/bosch_*/*_bosch owners (HTTPS and SSH), GHES and Bitbucket → ~/.config/git/work.gitconfig, any other github.com owner → ~/.config/git/private.gitconfig. Each sets identity plus the GitHub credential username and helper. A repository name ending in _bosch does not select the work identity.
  • git-credential-env VAR serves tokens from the environment or ~/.env (GITHUB_TOKEN, BDC_GITHUB_TOKEN, GITHUB_PRIVATE_TOKEN) and never stores them. When a GUI-started process lacks the token, it sources only ~/.shell/common/environment.sh in Bash; it does not start interactive shell initialization. For github.com the variable follows the host type: GITHUB_TOKEN on private hosts, GITHUB_PRIVATE_TOKEN on work hosts (where GITHUB_TOKEN is the work token); machine writes the choice to ~/.config/git/github-token.gitconfig on every dotfile apply. On private hosts machine setup also switches the checkout's origin to SSH (git@github.com:…) when the SSH key authenticates at GitHub, so pushing needs no token. ~/.netrc entries for the same host take precedence in curl, so keep GitHub out of it. machine env pull writes ~/.netrc from Bitwarden (see secrets.md) and warns for a github.com block. When such a block is needed (for example by the work devcontainers), private.gitconfig sets http.https://github.com/.proactiveAuth = basic, so Git asks the credential helper first and the netrc entry is not used for pushes and fetches in a repository; this needs Git 2.46 or newer, and a first git clone is not covered because no repository config exists yet.
  • Single repo with a different identity: git user-work / git user-private (repo-local include of the same snippet), undo with git user-unset-local; show: git user-show.
  • machine update and machine commit move host-only entries from the shared config into ~/.gitconfig.local. A key that is absent locally moves, an equal value is dropped from the shared file, and a different local value is a conflict that machine update asks about (non-interactive runs keep both and leave the shared file dirty). Repeated values are preserved. Backups live under ~/.local/share/machine/local-overrides-backup/. Text added to ~/.bashrc is handled the same way: known text is removed silently, new text is moved only when you select it, and moved text stands between # machine-local begin/end markers in ~/.bashrc-local.
  • The installed pre-commit hook does the same before an ordinary Git commit. If it changes the shared file, review and stage the cleaned file, then commit again.
  • CI runs python3 -m machine_cli.local_overrides --check and fails on committed host-only entries or invalid config. Hooks also run read-only when CI=true. Restricted keys include user identity/signing keys, signing settings, safe.*, credential.*, http.*, https.* and core.sshCommand; user.useConfigOnly remains shared.