Command referencegh alias set
gh alias set command (Linux & Windows / GitHub CLI)
What it does
Create a custom shortcut for a longer GitHub CLI command. When people search for gh alias 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.
Create a custom shortcut for a longer GitHub CLI command.
Syntax
gh alias set <alias> <expansion> [flags]
Common options
| Flag / option | Meaning |
|---|---|
| alias | Short name you will type after `gh`. |
| expansion | Full gh subcommand string to expand. |
| -s, --shell | Treat the expansion as a shell command. |
Practical examples
PR shortcut
gh alias set prc 'pr create --fill'
Lets you run `gh prc` to create a filled pull request.
Checks alias
gh alias set checks 'pr checks --watch'
Watches PR checks with a shorter command.
List aliases
gh alias list
Shows aliases you have configured.
Common mistakes
- Creating aliases that shadow built-in gh commands.
- Forgetting quotes around expansions that contain spaces.
Related commands
- gh configGet or set GitHub CLI configuration values such as git protocol and prompt behavior.
- gh pr createCreate a pull request from the current branch with title, body, reviewers, and base branch options.
- gh pr checksShow GitHub Actions and status-check results for a pull request.
- gh auth loginAuthenticate the GitHub CLI with GitHub.com or GitHub Enterprise so other gh commands can run.
- gh pr mergeMerge a pull request using merge commit, squash, or rebase strategies.
- gitTrack source history and collaborate through distributed repositories.
- gh repo cloneClone a GitHub repository to your machine using your authenticated gh settings.
- gh pr checkoutCheck out a pull request locally as a branch so you can build, test, or review the changes.
FAQ
What does gh alias set do in GitHub CLI?
Create a custom shortcut for a longer GitHub CLI command.
Does gh alias set 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 alias set example?
Try `gh alias set prc 'pr create --fill'` — Lets you run `gh prc` to create a filled pull request.
Do I need a token in the command line for gh alias set?
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.