Where Does the GitHub CLI Store Config and Tokens?
gh keeps hosts.yml (tokens) and config.yml (prefs) in a config dir settable via GH_CONFIG_DIR, defaulting per OS.
Last updated
gh splits two files: hosts.yml holds per-host OAuth tokens from gh auth login, config.yml holds preferences from gh config set (editor, protocol, prompt). Both live in one config directory.
That directory moves with GH_CONFIG_DIR, defaulting to $XDG_CONFIG_HOME/gh, then $AppData/GitHub CLI on Windows, then ~/.config/gh. Aliases and per-host settings ride along in the same folder.
Where GitHub CLI stores this, by platform
%APPDATA%\GitHub CLI
hosts.yml (tokens) plus config.yml (editor, git_protocol, prompt). Override the whole dir with GH_CONFIG_DIR; GITHUB_TOKEN env beats stored creds per run.
~/.config/gh
Same two files under ~/.config/gh (or $XDG_CONFIG_HOME/gh when set). gh auth refresh rotates tokens in place without touching preferences.
~/.config/gh
Same layout. gh config list shows effective prefs; per-host values set with --host land in the same config.yml.
Frequently asked questions
How do I move gh auth to another machine?
Copy the whole config dir to the new machine (scp -r works). Tokens travel with it, so treat the copy like a password and re-auth rather than sharing casually.
Can I point gh at a different config directory?
Set GH_CONFIG_DIR to the directory you want. gh uses it instead of all defaults, which isolates test identities from your real login.
Notice an outdated path? Let us know.