gh gist create Share a file or snippet as a GitHub gist

Uploads one or more files as a gist, a small shareable snippet with its own URL. Gists are secret (unlisted) by default.

Synopsis

gh gist create [FILE... | -] [FLAGS]

Common options

Option or formWhat it does
-p, --publicMake it public and searchable
-d, --desc TEXTAdd a description
-f, --filename NAMEName for text read from standard input
-w, --webOpen the gist in the browser
-Read the content from standard input

Examples

Share a file
gh gist create notes.txt
https://gist.github.com/octocat/abc123
Share several files with a description
gh gist create a.js b.js -d "Two helper functions"
Share command output
git diff | gh gist create -f changes.diff
Make it public
gh gist create --public setup.sh

Notes

See also

Last reviewed 2026-10-09.