22

I get this error when trying to push a Gist with folders in it to GitHub:

remote: Gist does not support directories.
remote: These are the directories that are causing problems:
remote: dirname1, dirname2

Looking at other questions, it seems that GitHub Gist doesn't accept empty folders, but none of these folders are empty. I can successfully push other files that are inside the root folder of the repository, and can also successfully deploy the app to Heroku using Git.

How do I add a directory to GitHub's Gist? What am I doing wrong here?

3
  • So what is your exact question?
    – simeg
    Dec 28, 2014 at 14:52
  • @simpe sorry .. the question is how do i add directories or what i am doing wrong that is preventing me from adding directories ?
    – sarincasm
    Dec 28, 2014 at 14:57
  • 2
    You likely want to push to github, not the gist page. Can you post the address of the repo to which you're pushing?
    – duhaime
    Dec 28, 2014 at 15:12

3 Answers 3

11

It's not possible, use a repository. Gists are only for files.

4
  • 19
    Please, copy here the comment. Sorry, that page doesn’t exist!
    – vesszabo
    Nov 4, 2018 at 8:38
  • "If you have a bunch of Gists that need to be grouped together, is there any reason that you're not turning these Gists into a repository or a series of repositories?" - github.community/t5/How-to-use-Git-and-GitHub/…
    – intotecho
    Mar 15, 2019 at 3:16
  • 2
    Yes, oftentimes because it isn't directly re-usable but still needs multiple directories. What a shame.
    – Ani
    Apr 25, 2019 at 19:42
  • Although the referenced tweet has been deleted, the "comment of a github developer" no doubt refers to the reply by Zach Holman: "Gists are for files, repositories are for directories." Dec 18, 2020 at 20:33
4

You cannot create folders, but you can have each "gist" begin with a prefix. So you can assign each gist to a "domain" or a "folder". If you want to search in a certain "folder" or "domain", you only have to enter the prefix.

1

There is a way to work around Gist's prohibition on directories: only the latest commit on each branch is checked for the presence of directories. If you create a commit with directories, then remove the directories in the next commit, you can push both commits together, then create a link to the commit with directories by appending /[commit] to the Gist URI.

The Gist UI handles this a bit weird: it seems to flatten out the directory structure, and display files across all directories. You can push branches, but branches other than master aren't linked to in the Gist UI anywhere. Commit URIs still work correctly though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.