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 get
gh config set
gh config unset
gh config list

PARAMETERS

get
    Retrieve the value associated with the specified configuration key.

set
    Set the value for the specified configuration key. value can be a string, boolean, or number.

unset
    Remove the configuration setting for the specified key, reverting to the default value (if any).

list
    Display all current configuration settings.

DESCRIPTION

The gh-config command is part of the GitHub CLI (gh) and allows users to manage their GitHub CLI configuration. It provides functionalities to view, set, and unset configuration settings that control how the gh tool interacts with the GitHub API and other services. This command is crucial for customizing the behavior of the GitHub CLI to match individual preferences, authentication details, and desired operational parameters.

Key aspects configurable using gh config include authentication tokens (though typically handled by gh auth), preferred text editor for commit messages and other tasks, browser to use for authentication flows, and other options relating to API interaction and display settings. The configuration is typically stored in a file (default is ~/.config/gh/config.yml) and is used to set defaults for other gh commands. Proper use of gh config can streamline interactions with GitHub repositories from the command line, enhancing productivity for developers.

CAVEATS

Modifying the configuration file directly instead of using gh config might lead to unexpected behavior if the file is not properly formatted. Be careful when editing the underlying YAML file manually. Some configuration values require specific formatting or data types.

CONFIGURATION FILE LOCATION

By default, gh stores its configuration in ~/.config/gh/config.yml. The location can be overridden by setting the GH_CONFIG_DIR environment variable.

COMMON CONFIGURATION KEYS

Some common configuration keys include: editor (preferred text editor), browser (preferred web browser), git_protocol (protocol used for Git operations), prompt (enable or disable interactive prompts).

HISTORY

The gh config command was introduced as part of the initial releases of the GitHub CLI (gh) when it was created by GitHub. It's evolved along with the gh tool to provide more flexibility in configuring the command-line interface. Prior to the GitHub CLI, users often relied on third-party tools or manual Git configuration to interact with GitHub from the command line. The gh tool simplifies many common tasks, including configuration management. The goal was to make the user experience smoother.

SEE ALSO

gh(1), gh auth(1)

Copied to clipboard