Skip to main content
A gist is GitHub’s lightweight way to share single files, code snippets, notes, or small utilities with built-in versioning. Think of it as a pastebin that supports revisions, forking, embedding, and cloning. This guide explains how to create public and secret gists, manage multiple files, view revisions, fork and embed gists, and clone them locally. Quick overview
  • Public gists are discoverable and indexed by GitHub.
  • Secret gists are unlisted (not indexed) but accessible by anyone with the URL — they are not private.
  • Every gist is a Git repository, so you can clone, edit, and push changes locally.
You can create a new gist from the GitHub header (plus icon → “New gist”), add one or more files, provide an optional description, and choose whether to create a public or secret gist. You can view your gists from your profile menu, and explore public gists at https://gist.github.com, filtering and sorting by date, stars, or forks.
The image shows a GitHub Gist page with lists of shell commands in files named "Mycommand.sh" and "Install.txt" under various users, along with sorting options for the gists.
Creating a public gist (step-by-step)
  • Click the plus icon → “New gist”.
  • Add a filename (for example, collision.js) and paste your snippet.
  • Optionally add a description and additional files.
  • Select Create public gist to make it discoverable.
Example public gist: collision.js
Public vs secret gists — quick comparison
Secret gists are not discoverable through GitHub search or public gist listings, but they are not private. Anyone with the direct URL can access them. Never store API keys, passwords, or other sensitive credentials in gists.
Creating a secret gist (example) Use a secret gist when you want to share small developer utilities with a limited audience. Paste your file(s), pick Create secret gist, and share the URL with the intended recipients. Example: internal developer helper (DevCheats)
Revisions and editing
  • Every edit you save creates a new revision for that gist.
  • From the gist page you can view the revision history, compare changes, and revert to an earlier revision if needed.
  • Use this when you want lightweight version control for single-file examples or small multi-file snippets.
Forking a gist
  • Any public gist can be forked to create an independent copy under your account.
  • Forks keep provenance metadata so you can track the original source.
  • Forking is useful for adding features, instrumentation, or examples without modifying the original gist.
Cloning a gist to your local machine Since gists are Git repositories, you can clone them and work locally. On a gist page, click Clone to copy the repository URL, then run git clone:
Other actions you can perform on a gist
  • Star a gist you find useful.
  • Edit your gist online or push changes after cloning locally.
  • Delete a gist you no longer want to keep.
  • Embed a gist in a webpage using the embed snippet GitHub provides.
  • Share the gist URL (for secret gists, share only with intended collaborators).
Summary Gists are an excellent tool for sharing small, versioned code examples, notes, or helper scripts. Use public gists to share with the community and secret gists for temporary or limited-distribution snippets. Because every gist is a Git repo, you can fork, clone, and revise gists using familiar Git workflows. Links and references

Watch Video