Skip to main content

Command referencegh gist create

gh gist create command (Linux & Windows / GitHub CLI)

Linux & WindowsGitHub CLIgitbeginner

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 / optionMeaning
-d, --descGist description.
-f, --filenameFilename when reading from stdin.
-p, --publicCreate a public gist (default is secret).
-w, --webOpen 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.py

Creates 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.

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.