Little Known Ways To Utilize GitHub Gists

Reading Time: 5 minutes

What is Gist?

Gist is an easy method to share snippets or excerpts of data with others. A gist can be a string of code, a bash script or some other small piece of data. These bits of information are hosted by GitHub as a repository. Using gist has all the benefits of utilizing a GitHub repository, and also provides a more lightweight way of utilizing GitHub’s versioning features. 

A gist can be either public or secret. If you are logged in to GitHub when you create a gist, it will show up in your dashboard. You can also drag and drop a file onto your gist editor and it will be added 

Not only are gists free to create and store on GitHub, but they are also easy to create. You can add a new gist, modify, and delete files and code entirely from within your browser. Lastly, there is no need to download or install a program to use gist.

How Do I Create a Gist?

Creating a gist is simple. Here are the steps to add a gist to your GitHub account.

1, Sign in to GitHub

2. Browse to your gist homepage.

3. Type in a name and description for our gist. 


4. Type in the text you want to save into the text field. In this instance, we are adding a ‘du -sk’ command.


5. Select if the gist will be public or private. Click on your selection and your gist will be created.

If you are logged in to GitHub and on the main page, you also have the option of clicking on the plus sign “+” next to your profile icon as seen below. This will open a dropdown menu where you can select the “New gist” option.

How Do I Edit or Delete a Gist?

In the top right corner of your gist page, there will be a menu that allows for multiple functions to be performed on your gist.


We can edit, delete, unsubscribe, star, embed, copy, share, and download a raw copy or zipped copy of a gist.

We also can share a gist in multiple ways. You can opt to embed the gist into a website, copy a shareable link to send, clone (or copy) the gist via the git command to a local repository or via SSH. 


Review Your Gists

Once you have logged into your GitHub account, click on your username in the top right corner. This will open a menu where you can see an option called ‘Your gists’.

Once you clicked that option, you will see your gist page.

Create A Gist From the Command Line

We also can create a gist via the command line without having to actually log in to GitHub. This does require you to create a personal access token from the settings’ menu.


Simply click on the “Generate new token” button on the top right-hand side. This will open a new window where you can create a new access token. Simply add a name for the token in the note field.


Next, select a scope from the available options.

We will choose the gist option.


Then, we can click on the green “Generate token” button at the bottom of the available scopes page. This will open a new page that contains your new secret token.


As the note states, Make sure you copy your new personal access token to a safe place as it will not be shown again.

We can now use that token as our password to access the GitHub API functions.

To add a gist via the command line, we can use the following command.

curl -X POST -d '{"public":true,"files":{"addgist.txt":{"content":"This is a cool way to add a gist!"}}}' -u MyUser:194be7ef18ae5c539cc75bd830f03d3487b118fc
  • This is all one command you will copy into your command line. 
  • You can modify the “public”:true, to false if you wish to add a secret gist.
  • You can modify the “Addgist.txt” to whatever you would like to name your gist. 
  • We can also add specific content to your gist by modifying the “This is a cool way to add a gist!” section.
  • Lastly, change the ‘MyUser’ option to your GitHub username, and then enter the personal access token we copied in the last step as your password.

When we run the above command, we will get output on the command line which looks like this.

root@host [~]# curl -X POST -d '{"public":true,"files":{"addgist.txt":{"content":"This is a cool way to add a gist!"}}}' -u MyUser:194be7ef18ae5c539cc75bd830f03d3487b118fc
  "url": "",
  "forks_url": "",
  "commits_url": "",
  "id": "8c1d63fa3400f1f00f3d63bf50670794",
  "node_id": "MDQ6R2lzdDhjMWQ2M2ZhMzQwMGYxZjAwZjNkNjNiZjUwNjcwNzk0",
  "git_pull_url": "",
  "git_push_url": "",
  "html_url": "",
  "files": {
    "addgist.txt": {
      "filename": "addgist.txt",
      "type": "text/plain",
      "language": "Text",
      "raw_url": "",
      "size": 33,
      "truncated": false,
      "content": "This is a cool way to add a gist!"
  "public": true,
  "created_at": "2020-02-26T22:35:32Z",
  "updated_at": "2020-02-26T22:35:32Z",
  "description": null,
  "comments": 0,
  "user": null,
  "comments_url": "",
  "owner": {
    "login": "MyUser",
    "id": 5208558,
    "node_id": "MDQ6VXNlcjUyMDg1NTg=",
    "avatar_url": "",
    "gravatar_id": "",
    "url": "",
    "html_url": "",
    "followers_url": "",
    "following_url": "{/other_user}",
    "gists_url": "{/gist_id}",
    "starred_url": "{/owner}{/repo}",
    "subscriptions_url": "",
    "organizations_url": "",
    "repos_url": "",
    "events_url": "{/privacy}",
    "received_events_url": "",
    "type": "User",
    "site_admin": false
  "forks": [

  "history": [
      "user": {
        "login": "MyUser",
        "id": 5208558,
        "node_id": "MDQ6VXNlcjUyMDg1NTg=",
        "avatar_url": "",
        "gravatar_id": "",
        "url": "",
        "html_url": "",
        "followers_url": "",
        "following_url": "{/other_user}",
        "gists_url": "{/gist_id}",
        "starred_url": "{/owner}{/repo}",
        "subscriptions_url": "",
        "organizations_url": "",
        "repos_url": "",
        "events_url": "{/privacy}",
        "received_events_url": "",
        "type": "User",
        "site_admin": false
      "version": "c42194dfef53dfb3d6fea5f057c29959af53e635",
      "committed_at": "2020-02-26T22:35:32Z",
      "change_status": {
        "total": 1,
        "additions": 1,
        "deletions": 0
      "url": ""
  "truncated": false
root@host [~]# 

Now, if we go back to our gist list, we can see the new gist has been added!


How Can Gists Be Used?

There are multiple ways to utilize gists. Here are a few examples we have found that are very useful in our daily activities.

  • As a task lists.
  • Organize notes.
  • As a writing platform.
  • To Save links.
  • To Write anonymous text.
  • Track text changes.
  • Publish rich text gists (using markdown and saving as an .md file).
  • To host a simple website.
  • Code can be embedded within a web page or WordPress post.
  • Can be used to bookmark websites. 
  • Store configuration or other .dotfiles.
  • Share gists on social media.
  • Associate multiple files to a single Gist.
  • Miniblog.
  • ‘Secret’ Text gist.
  • Sync VS Code as a gist.
  • Use a Python gist as a command line client.
  • The API is straightforward to integrate with your project or software. When creating a gist, you can easily send a POST request to add a gist.
  • Reviewing tool to exchange/review info with others.
  • Upload images to a gist — clone your gist as a git repository and add your picture, then push to origin. 
  • Backup with versioning.

Other Uses For Gists

In addition to the above uses, this post outlines how gist can be uses as a syntax highlighter. There are also several third-party services that have been created specifically around the use of gists.


As you can see, gist are a handy way to store random data you create. Gists have a multitude of uses that is only limited by your imagination!

Have questions about how gists can be more useful? Give us a call at 800.580.4985, or open a chat or ticket with us to speak with one of our knowledgeable Solutions Team or an experienced Hosting Advisor today!

Author Bio

About the Author: David Singer

I am a g33k, Linux blogger, developer, student and Tech Writer for My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Refer a friend and get hosting credit!