LinuxCommandLibrary

gh-config

Configure GitHub CLI settings

TLDR

Display what Git protocol is being used

$ gh config get git_protocol
copy

Set protocol to SSH
$ gh config set git_protocol ssh
copy

Use delta in side-by-side mode as the default pager for all gh commands
$ gh config set pager 'delta --side-by-side'
copy

Set text editor to Vim
$ gh config set editor [vim]
copy

Reset to default text editor
$ gh config set editor ""
copy

Disable interactive prompts
$ gh config set prompt [disabled]
copy

Set a specific configuration value
$ gh config set [key] [value]
copy

SYNOPSIS

gh config <command> [<flags>]

PARAMETERS

edit
    Edit configuration interactively in $EDITOR

get <key>
    Get value for specified key

list
    List all keys and their values

set <key> [<value>]
    Set key to value (boolean keys toggle)

--host <host>
    Config for specific host (default github.com)

--scope <scope>
    Scope: global|user|repo (default global)

-h, --help
    Show command help

--version
    Print gh version

DESCRIPTION

The gh config command manages settings for the GitHub CLI (gh), similar to git config. It handles viewing, setting, listing, and editing configuration stored in YAML files, primarily at $XDG_CONFIG_HOME/gh/config.yml (defaults to ~/.config/gh/config.yml). Supports scopes like global (user-wide), user, repo (git repository-specific), and host-specific configs.

Key subcommands include:
set: Assign values, e.g., gh config set editor vim.
get: Retrieve a value, e.g., gh config get prompt.
list: Display all keys/values.
edit: Open config in $EDITOR or default editor.

Common keys control behavior: prompt (yes/no), git_protocol (ssh/https), browser, pager, aliases. Host flag allows per-host configs (e.g., enterprise). Ideal for customizing prompts, pagination, and integrations without environment variables.

CAVEATS

YAML syntax required; malformed files cause parse errors.
Repo scope needs git repo context.
Manual edits risk invalidation—prefer commands.

COMMON KEYS

editor: Text editor
prompt: Interactive prompts (yes/no)
git_protocol: ssh|https
paginate: yes|no|never

FILE LOCATIONS

Global: $XDG_CONFIG_HOME/gh/config.yml
Repo: .git/config [gh-config]
Per-host: prefixed by host key.

HISTORY

Debuted in GitHub CLI v0.5.0 (Feb 2020); evolved with v1.0 (2021) for stable YAML support and scopes, mirroring git config patterns.

SEE ALSO

git config(1), gh(1)

Copied to clipboard