Command referencegh config
gh config command (Linux & Windows / GitHub CLI)
What it does
Get or set GitHub CLI configuration values such as git protocol and prompt behavior. When people search for gh config set, they usually want practical GitHub CLI flags, safe examples, and how this subcommand fits everyday PR and repo workflows on Linux, Windows, and macOS. Syntax, options, and copyable examples are below.
Get or set GitHub CLI configuration values such as git protocol and prompt behavior.
Syntax
gh config <get|set|list> [key] [value]
Common options
| Flag / option | Meaning |
|---|---|
| list | Print all configuration keys and values. |
| get KEY | Print one configuration value. |
| set KEY VALUE | Write a configuration value. |
| git_protocol | Common key: https or ssh. |
| prompt | Enable or disable interactive prompts. |
Practical examples
List config
gh config list
Shows current gh configuration entries.
Prefer HTTPS
gh config set git_protocol https
Makes clone/fetch remotes use HTTPS by default.
Read a key
gh config get git_protocol
Prints the configured git protocol.
Disable prompts
gh config set prompt disabled
Useful in non-interactive scripts that must not hang.
Common mistakes
- Setting protocol after remotes already exist and expecting old remotes to rewrite themselves.
- Disabling prompts globally and then wondering why interactive commands fail.
Related commands
- gh auth loginAuthenticate the GitHub CLI with GitHub.com or GitHub Enterprise so other gh commands can run.
- gh repo cloneClone a GitHub repository to your machine using your authenticated gh settings.
- gh alias setCreate a custom shortcut for a longer GitHub CLI command.
- gh pr createCreate a pull request from the current branch with title, body, reviewers, and base branch options.
- gh pr mergeMerge a pull request using merge commit, squash, or rebase strategies.
- gitTrack source history and collaborate through distributed repositories.
- gh pr checkoutCheck out a pull request locally as a branch so you can build, test, or review the changes.
- gh pr listList pull requests in a repository with state, author, and search filters.
FAQ
What does gh config do in GitHub CLI?
Get or set GitHub CLI configuration values such as git protocol and prompt behavior.
Does gh config work on Windows and Linux?
Yes. The GitHub CLI (`gh`) runs on Linux, Windows, and macOS with the same subcommand syntax after you authenticate with `gh auth login`.
What is a practical gh config example?
Try `gh config list` — Shows current gh configuration entries.
Do I need a token in the command line for gh config?
Prefer `gh auth login` so credentials stay in the system keyring or secure storage. Avoid pasting personal access tokens into shell history.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.