我们经常发布文档更新,此页面的翻译可能仍在进行中。有关最新信息,请访问英文文档。如果此页面上的翻译有问题,请告诉我们

此版本的 GitHub Enterprise 已停止服务 2021-03-02. 即使针对重大安全问题,也不会发布补丁。 要获得更好的性能、改进的安全性和新功能,请升级到 GitHub Enterprise 的最新版本。 如需升级方面的帮助,请联系 GitHub Enterprise 支持

Creating gists

You can create two kinds of gists: public and secret. Create a public gist if you're ready to share your ideas with the world or a secret gist if you're not.

本文内容

About gists

Every gist is a Git repository, which means that it can be forked and cloned. If you are signed in to GitHub Enterprise Server when you create a gist, the gist will be associated with your account and you will see it in your list of gists when you navigate to your gist 主页 http(s)://[hostname]/gisthttp(s)://gist.[hostname] 如果启用了子域.

Gists can be public or secret. Public gists show up in Discover http(s)://[hostname]/gist/discoverhttp(s)://gist.[hostname]/discover(如果启用了子域), where people can browse new gists as they're created. They're also searchable, so you can use them if you'd like other people to find and see your work.

Secret gists don't show up in Discover http(s)://[hostname]/gist/discoverhttp(s)://gist.[hostname]/discover(如果启用了子域) and are not searchable. Secret gists aren't private. If you send the URL of a secret gist to a friend , they'll be able to see it. However, if someone you don't know discovers the URL, they'll also be able to see your gist. If you need to keep your code away from prying eyes, you may want to create a private repository instead.

在创建 Gist 后,不可将其从公共转换为机密。

If your site administrator has disabled private mode, you can also use anonymous gists, which can be public or secret.

警告:匿名 gists 不能从Web 浏览器中删除。 若要删除匿名 Gist,请联系 您的站点管理员。 请提供您想要删除的 Gist 的 URL。

You'll receive a notification when:

  • You are the author of a gist.
  • Someone mentions you in a gist.
  • You subscribe to a gist, by clicking Subscribe at the top any gist.

You can pin gists to your profile so other people can see them easily. For more information, see "Pinning items to your profile."

You can discover public gists others have created by going to the gist 主页 http(s)://[hostname]/gisthttp(s)://gist.[hostname] 如果启用了子域 and clicking All Gists. This will take you to a page of all gists sorted and displayed by time of creation or update. You can also search gists by language with Gist 搜索 http(s)://[hostname]/gist/searchhttp(s)://gist.[hostname]/search(如果启用了子域). Gist search uses the same search syntax as code search.

Since gists are Git repositories, you can view their full commit history, complete with diffs. You can also fork or clone gists. For more information, see "Forking and cloning gists".

You can download a ZIP file of a gist by clicking the Download ZIP button at the top of the gist. You can embed a gist in any text field that supports Javascript, such as a blog post. To get the embed code, click the clipboard icon next to the Embed URL of a gist. To embed a specific gist file, append the Embed URL with ?file=FILENAME.

Creating a gist

You can also drag and drop a text file from your desktop directly into the gist editor.

You can also create a gist using the GitHub CLI. For more information, see "gh gist create" in the GitHub CLI documentation.

  1. Sign in to GitHub Enterprise Server.

  2. Navigate to your gist 主页 http(s)://[hostname]/gisthttp(s)://gist.[hostname] 如果启用了子域.

  3. Type an optional description and name for your gist.

    Gist name description

  4. Type the text of your gist into the gist text box.

    Gist text box

  5. Optionally, to create a public gist, click , then click Create public gist.

    Drop-down menu to select gist visibility

  6. Click Create secret Gist or Create public gist.

    Button to create gist