Command referencegh gist create
gh gist create command (Linux & Windows / GitHub CLI)
What it does
Create a GitHub gist from files or standard input for quick snippets and scratch notes. When people search for gh gist create, 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 GitHub gist from files or standard input for quick snippets and scratch notes.
Syntax
gh gist create [<filename>... | <directory> | -] [flags]
Common options
| Flag / option | Meaning |
|---|---|
| -d, --desc | Gist description. |
| -f, --filename | Filename when reading from stdin. |
| -p, --public | Create a public gist (default is secret). |
| -w, --web | Open the gist in a browser after creation. |
Practical examples
From a file
gh gist create ./notes.md -d "Debug notes"
Uploads notes.md as a secret gist by default.
From stdin
echo "print('hi')" | gh gist create -f hello.pyCreates a gist named hello.py from piped input.
Public gist
gh gist create ./snippet.sh --public
Publishes a public gist — avoid secrets.
Common mistakes
- Creating a public gist that contains tokens or private URLs.
- Assuming secret gists are fully private — the URL is still shareable.
Related commands
- gh apiMake authenticated HTTP requests to the GitHub REST or GraphQL API using your gh credentials.
- gh browseOpen a GitHub repository, issue, pull request, or path in the browser.
- gh auth loginAuthenticate the GitHub CLI with GitHub.com or GitHub Enterprise so other gh commands can run.
- 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 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 gist create do in GitHub CLI?
Create a GitHub gist from files or standard input for quick snippets and scratch notes.
Does gh gist create 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 gist create example?
Try `gh gist create ./notes.md -d "Debug notes"` — Uploads notes.md as a secret gist by default.
Do I need a token in the command line for gh gist create?
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.