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 set key value [flags]
gh config get key [flags]
gh config list [flags]
gh config unset key [flags]

PARAMETERS

set key value
    Configures a specified key with a new value. If the key already exists, its value is updated.

get key
    Retrieves and displays the current value for a given configuration key.

list
    Lists all currently set configuration keys and their corresponding values.

unset key
    Removes a specified configuration key and its associated value.

--host hostname
    Applies the configuration operation to a specific GitHub Enterprise Server hostname instead of the default github.com.

DESCRIPTION

gh-config is a subcommand of the GitHub CLI (gh) designed to manage its configuration settings. It allows users to view, set, or unset various preferences that affect the CLI's behavior. These settings are stored in a config.yml file, typically located in ~/.config/gh/. Users can configure parameters such as the default text editor, pager, Git protocol (SSH or HTTPS), prompt behaviors, and host-specific settings. This command provides a standardized way to customize the gh experience without directly editing the YAML file, ensuring consistency and ease of management for both global and host-specific configurations.

CAVEATS

gh-config manages settings typically stored in ~/.config/gh/config.yml. Manually editing this file can lead to syntax errors that gh-config might not detect, potentially breaking CLI functionality. Be cautious when setting values for critical parameters like git_protocol as incorrect settings can prevent Git operations. Some configuration keys might be host-specific, requiring the --host flag for proper management.

CONFIGURATION FILE LOCATION

The primary configuration file managed by gh-config is typically located at ~/.config/gh/config.yml. This YAML file stores all global and host-specific settings for the GitHub CLI.

COMMON CONFIGURATION KEYS

Some frequently configured keys include:
editor: Specifies the command used to open text files (e.g., for issue/PR descriptions).
pager: Defines the command for paginating long output (e.g., less or most).
git_protocol: Determines whether Git operations (e.g., cloning) use ssh or https.
prompt: Controls various interactive prompt behaviors, such as whether to ask for confirmation.
http_unix_socket: (Advanced) Specifies a Unix socket for HTTP communication, useful for proxying.

HISTORY

The gh-config command is an integral part of the GitHub CLI, which was officially released in 2020. Its development aimed to provide a user-friendly and consistent way for users to manage their CLI preferences, replacing the need for direct YAML file manipulation. It has evolved alongside the gh tool, adapting to new features and configuration needs since its inception.

SEE ALSO

gh(1), git-config(1)

Copied to clipboard