135

Is there a way to change the name of a gist (github) ?, apparently it is ordering the files of the gist in alphabetical order, an naming the gist according to the file that appears first.

Sebastian Castano
  • 1,491
  • 2
  • 9
  • 8

7 Answers7

85

Even better, you can add a file with a leading space in its name. It's virtually invisible and gives you more freedom when choosing the title and names for the files: enter image description here

  • 2
    Also, in lieu of adding a space to the file to want to be first, you can add a tilde ~ to every file you want to be last. – jordanbtucker Jul 24 '14 at 04:08
  • 77
    Why doesn't the name just use the title/description you have to type? Absolutely absurd the way it uses the file name. – void.pointer Oct 07 '14 at 20:49
  • 11
    How strange: editing the gist appears to strip the leading space from filenames. If you are using this strategy to add a "header file" to your gists, be sure to re-add that leading space every time that you edit. – Dave Hughes Nov 18 '14 at 16:57
  • 1
    I've now experimented with this for a bit and found I like leading dots `.` the best, possibly because I'm already used to seeing files with them. I use leading underscores (as mentioned by @Cedric) on my file system but noticed that for some reason, gist files with a leading `_` move _below_ names starting with a capital letter once in edit mode... – Kay Dec 04 '15 at 16:32
  • 1
    I'm finding today that the editing GUI will still strip out leading spaces now regardless of trying to make sure they're in there, but ... pushes up from a git clone of the gist will still respect them at the beginning of filenames, so this hack still kinda works, but fragile (limits editing to git clone pushes, and subject to GitHub's whims for potential future changes again). – Max Starkenburg Feb 13 '21 at 20:19
  • Invisible in what way, and why would i want that? – johny why Nov 27 '22 at 19:27
57

Considering the order of files within a gist is asciibetical, you can try and add one file in uppercase.

That file will come before any other and will define the name of your gist.

Note that it won't change the url of said gist, as explained in "Namespaced Gists".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This appears to no longer work, is there an updated method, or more details? – Drazisil Mar 30 '18 at 15:33
  • 1
    @Drazisil I just tested it: it does work (in my case, with a number: https://gist.github.com/VonC/6006076) (since numbers comes before letters, as I explained in https://stackoverflow.com/a/17668995/6309) – VonC Mar 30 '18 at 21:19
  • @VonC Well, huh. I swear I tried that, but I must have gone with another form. Thanks :) – Drazisil Mar 31 '18 at 23:22
  • 1
    I add a file with ".Title starting with dot" to ensure the correct one is displayed and on top. – shadowbq Jan 17 '20 at 18:18
  • As of August 2020, @ChumaUmenze has the most up to date [answer](https://stackoverflow.com/questions/19896900/how-to-change-the-name-of-a-gist-in-github#answer-62398008), although prefixing spaces doesn't work – Ibraheem Ahmed Aug 25 '20 at 19:28
30

Currently, there's no way rename a Github gist. There's been an open issue on this. I would suggest you add a text file to your gist. The file name should start with space ( ), a hash sign (#), an exclamation mark (!), a dollar sign ($) or an ampersand (&). You can add a long description to the body.

For example, naming your file #Github Tricks will change your gist title to #Github Tricks. This will also work if your file name starts with a space ( ) like Github Tricks. If both files exist, the title starting with space takes precedence.

The file names in your gist determine the gist title. The order is listed below.

\t, \n, \x0b, \x0c, \r, , !, ", #, $, %, &, \', (, ), *, +, ,, -, ., /, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, :, ;, <, =, >, ?, @, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, [, \\, ], ^, _, `, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, {, |, }, ~

Chuma Umenze
  • 933
  • 12
  • 18
  • 1
    the starting with space did not work. But starting with # worked. thanks a lot. a fantastic trick, – aahnik Dec 08 '20 at 11:02
  • Using space should work. That's what I use all the time see: https://gist.github.com/chumaumenze/72ddd3b0a3b19136d29e92fe27870898 or https://gist.github.com/chumaumenze/b15a2d64b95294a8bac3218384a6c9a7 – Chuma Umenze Dec 09 '20 at 19:18
17

What I do is creating a first file with leading underscore example : '_simple gist.md' and set it's type as markdown so it also serves as description of my gist .. after reading this post, I will prefix a leading space.

Cedric Dumont
  • 1,009
  • 17
  • 38
13

An even better way is to use an ! (exclamation) in front of the name of the file that you always want to be the first in the order. That way you avoid having to add a space everytime you edit the file, as well as adding a tilde ~ to all the remaining files which can be an arbitrary long list.

Thinker
  • 303
  • 4
  • 13
  • This solution is **much better** than the space. The exclamation mark renders nearly the same result (it's only two chars greater than space) except it doesn't get lost every time you edit the gist in a browser. – Daniel Liuzzi Oct 19 '19 at 23:36
  • I really like this solution, for the second part "as well as adding a tilde to all the remaining files" Because gists carry the implicit all rights reserved license, if you want your gist to actually be open source, you need to include a license (maybe the description is sufficient, idk). If your gist is one file, with a lower-case name, eg `processing_data.py`, then making a gist of that + LICENSE will always result in a gist named LICENSE. The `~` prefix means a clean title for your actual gist, always – Matthew Strasiotto Mar 15 '21 at 07:56
6

If you edit the Gist an input box with the filename appears. That can be used to change the filename.

FrVaBe
  • 47,963
  • 16
  • 124
  • 157
2

My gist contained a .gitignore which sorts above a leading underscore. I ending up using two leading periods: ..FutureProcessorWithShinyExample.md

PeterVermont
  • 1,922
  • 23
  • 18