How to create a GitHub Gist

Updated · DeskHowTo

On GitHub (verified 2026-10-24), open https://gist.github.com while signed in, enter a description, add a filename with extension (for example demo.py), paste the code, choose Create public gist or Create secret gist, and save. You get a URL to share; secret gists are unlisted (not private encryption) — anyone with the link can view them.

Gists are ideal for repro snippets, config samples and tiny scripts. Multi-file gists keep related files together. For real projects with issues and PRs, create a repository instead.

Jump to

Applies to GitHub.com (and Enterprise when Gist is enabled). You need a GitHub account. Secret ≠ private: treat secret gists as shareable links, not vault storage.

Publish a public or secret Gist

Open the Gist editor

  1. Sign in to GitHub.
  2. Go to https://gist.github.com (or profile menu → Your gists → New).
  3. Add an optional description.

Add files

  1. Enter a filename including the extension so syntax highlighting works.
  2. Paste the snippet.
  3. Optional: Add file for a second related file in the same gist.

Create and share

  1. Click Create public gist or Create secret gist.
  2. Copy the gist URL to share.
  3. Optional: clone with the git URL on the gist page if you will iterate locally.

Our take: secret for drafts, public for teaching

Public gists are discoverable; secret gists are fine for a quick Slack paste but never for passwords or tokens.

If it fails

  • Create button disabled: empty filename or empty file body — fill both.
  • Secret gist still leaked: anyone with the URL can open it; revoke by deleting the gist.
  • Need reviewers/PRs: promote the work to a proper repository.
  • Enterprise gist disabled: ask your admin — some orgs turn Gist off.

Frequently asked questions

What is a GitHub Gist?

A lightweight snippet host on GitHub for one or more files with a shareable URL and optional git access.

Public vs secret gist?

Public gists can appear in discovery/search; secret gists are unlisted but viewable by anyone who has the link.

Can a gist have multiple files?

Yes — use Add file before creating the gist.

Are secret gists private?

No — they are secret/unlisted, not access-controlled private repos. Do not store credentials.

How do I edit a gist later?

Open the gist → Edit → change files → Update.