Articles
Published · November 18, 2026

Secret vs Public Gists: Sharing a Snippet Without Publishing It

A secret gist is unlisted, not private: it stays out of Discover and search, but anyone with the URL can read it. Here is how the two kinds differ and how to clone a gist.

Also in: Español中文हिन्दी

A secret gist is unlisted, not private. It stays out of GitHub's Discover page and out of search, but anyone who has the URL can open it. A public gist is listed and searchable. Pick secret when you want to hand someone a snippet without publishing it, and never when the contents must stay hidden.

Here's what each kind does, how to switch between them, how to clone a gist as a tiny repository, and when a private repository is the better call.

What public and secret gists mean

GitHub's docs put it in one line: "Create a public gist if you're ready to share your ideas with the world or a secret gist if you're not." The difference is discoverability, not access control.

Public gists: listed and searchable

Public gists show up in Discover, where people can browse new gists as they're created, and they're searchable. Post one and strangers can find it.

Secret gists: unlisted, not private

Secret gists don't show up in Discover and aren't searchable, unless you're logged in and are the author. The same docs page is blunt about the limit: secret gists aren't private. If you send the URL to a friend, they can see it. If someone you don't know discovers the URL, they can see it too.

So the URL is your only protection. Treat it like a link in a chat message: fine for a colleague, wrong for anything that would hurt if it leaked.

GitHub does scan secret gists for partner secrets and informs the relevant partner when one of their secrets is leaked. That is a cleanup aid, not a reason to paste a key into one.

| | Public gist | Secret gist | | --- | --- | --- | | Shown in Discover | Yes | No | | Searchable | Yes | Only by you, its author, when logged in | | Readable with the URL | Yes | Yes | | Can be made public later | Already public | Yes | | Can be made secret later | No | Already secret |

Create one, and why the choice is one-way

On the web: sign in, open the gist home page, click the plus icon, add an optional description, give the file a name including its extension, paste the contents, then choose Create public gist or Create secret Gist from the button's dropdown. You can also create gists from the terminal with the GitHub CLI's gh gist create.

The visibility switch only goes one way. In the docs' words, after creating a gist you cannot convert it from public to secret, while a secret gist can be made public by editing it and updating the visibility.

Not sure which to pick? Start secret. You can publish it later. You can't take a public gist back to secret, and a public gist may already have been found and copied.

Cloning a gist as a small snippet repo

Every gist is a Git repository, which means you can fork or clone any gist you can see, even if you aren't its author. To clone one, open the gist, select the Embed dropdown, then click Clone via HTTPS or Clone via SSH. The docs don't print the URL format, so copy it from there.

git clone <gist-clone-url> my-snippet
cd my-snippet

`git clone` copies the repository into a new directory, creates remote-tracking branches, and checks out an initial branch. The directory name is optional; without it, Git derives one from the source, and cloning into an existing directory only works if it is empty.

Edit the file, commit, and send it back like any other repository:

git add snippet.py
git commit -m "Handle empty input"
git push origin <branch>

Per Pro Git, origin is the default name Git gives the server you cloned from, and git push <remote> <branch> works only if you have write access and nobody has pushed in the meantime. Without write access to a gist, fork it and work on your copy.

If you want to point a teammate at one specific line inside a repository rather than a whole gist, share a line range with a GitHub permalink.

Revisions and forks

Because a gist is a repository, it keeps history. Click the Revisions tab at the top of a gist to see its full commit history with diffs. Each gist also shows which forks have activity, so you can spot interesting changes from other people.

After cloning, the whole history is on your machine, so git log -S and -G can find when a line appeared or vanished, the same way they do in a notes repository.

When a private repository is the better choice

If code needs to stay out of sight, use a private repository. GitHub's own guidance points there for anything you want to keep from prying eyes. Passwords, API tokens, customer data, unreleased work: none of it belongs in a gist of either kind.

A gist is a good fit for a short, self-contained snippet: a shell one-liner, a config fragment, a function you want a colleague to try. Once it needs issues, review, or a team, move it to a repository, where GitHub Markdown references such as #26 and @username work in conversations.

How Carets fits in

Before a snippet becomes a gist, it usually lives in a file somewhere. Carets is a native notes and code editor for iPhone, iPad, and Mac, with syntax highlighting for code and config files, and files organized into projects and tags. Keep your snippet library there as plain text, check a file over before you paste it into a gist, and clone a gist to a folder to edit it on your Mac with the same editor. Your files stay plain text, so they stay portable.

Download Carets for iPhone, iPad, and Mac on the App Store.

Frequently Asked Questions

Can anyone find a secret gist?

Not by browsing or searching. Secret gists don't show up in Discover and aren't searchable unless you're logged in as the author. But anyone who has or discovers the URL can view the gist.

Can I turn a public gist into a secret one?

No. GitHub says you cannot convert a public gist to secret. A secret gist can be made public by editing the gist and setting its visibility to public.

Is a gist a Git repository?

Yes. Every gist is a Git repository, so it can be forked and cloned, and its Revisions tab shows the full commit history with diffs.

What should I use for code that must stay private?

A private repository. GitHub's docs state that secret gists aren't private and suggest a private repository for code you want to keep from prying eyes.