Github Gist
- GitHub Gists are a simple way to share code snippets with others.
- Every gist is a Git repository, meaning it can be forked and cloned.
- When you are signed in to GitHub and you create a gist, then it gets associated with your account and you can navigate to - Gist Homepage
- Gists can either be Public or Secret. Public Gists show up in Discover.
- Secret Gists don't appear in Discover but are not private. Anyone who has the gist URL can see the secret gist.
- If you want to keep your code private, you might want to create a Private Repo.
- Remember that you cannot convert a Public Gist into a Secret Gist, however, a secret gist can be changed to a public one by changing its visibility.
- Since Gists are also repositories, you can clone/fork it, add changes to it, and see the update history.
Creating a gist
1. Sign in to GitHub
2. Navigate to Gist Homepage
3. Optionally, in the "Gist description" field, type a description for your gist.
4. In the "Filename including extension" field, type a file name for your gist, including the file extensions.
5. In the file contents field, type the text of your gist.
6. Optionally, to create a public gist, click dropdown, then click Create public gist.
7. Click Create secret Gist or Create public gist.
Forking and Cloning a gist
1. Each gist indicates which forks have activity, making it easy to find interesting changes from others.
2. To clone a gist, select the Embed dropdown menu, then click Clone via HTTPS or Clone via SSH.
Viewing gist commit history
To view a gist's full commit history, click the "Revisions" tab at the top of the gist. You will see a full commit history for the gist with diffs.
Starring a gist
1. Navigate to Discover and select the gist you want to star.
2. To star the gist, click ⭐ in the top-right corner of the page.
3. You can see all the gists starred by going to your Gist starred page.
Note -
You can also create a gist using the GitHub CLI. For more information, see "gh gist create"
in the GitHub CLI documentation.
Alternatively, you can drag and drop a text file from your desktop directly into the editor.