Skip to main content

Command referencegh alias set

gh alias set command (Linux & Windows / GitHub CLI)

Linux & WindowsGitHub CLIgitintermediate

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 / optionMeaning
aliasShort name you will type after `gh`.
expansionFull gh subcommand string to expand.
-s, --shellTreat 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.

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.