gh config set: Configure gh Behavior in CI
gh config set changes a gh CLI configuration value such as the git protocol, pager, or prompt setting.
On a runner you usually want gh non-interactive and pager-free; gh config set adjusts those defaults once at the start of a job.
What it does
gh config set writes a key-value pair into the gh configuration. Useful keys include git_protocol (https or ssh), prompt (enabled or disabled), and pager. --host scopes the setting to a specific GitHub host.
Common usage
gh config set prompt disabled
gh config set git_protocol https
gh config set pager cat
gh config set git_protocol ssh --host github.example.comFlags
| Key / Flag | What it does |
|---|---|
| prompt <enabled|disabled> | Toggle interactive prompts |
| git_protocol <https|ssh> | Protocol gh uses for git operations |
| pager <program> | Pager to use (cat disables paging) |
| editor <program> | Default editor for gh |
| -h, --host <host> | Scope the setting to a GitHub host |
In CI
Most prompts are already suppressed when no TTY is present, but gh config set prompt disabled makes it explicit. Set pager cat (or export GH_PAGER=cat) so long output never blocks on a pager, and pick git_protocol https when only GH_TOKEN is available.
Common errors in CI
gh config set rarely errors, but an invalid key is silently stored and ignored, so a typo like git_protcol has no effect; verify with gh config get. A command that still hangs in CI usually means a different interactive prompt, not the pager, so also disable prompts.
Using this in CI
CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.
- uses: actions/checkout@v4
with:
fetch-depth: 0 # history, tags, and git describe all need this
- run: |
git rev-parse --is-shallow-repository # expect false
git rev-parse --abbrev-ref HEAD # prints HEAD when detached