Add another file to existing GitHub Gist

Click Edit

Edit Gist

...and then Add file

Add file


Go to your Gist and click the Edit button at the top right.

The Gist editor will show your files in edit mode, then look at the bottom left and there you will find an 'Add file' button.

Click it and the cursor will be moved to the 'File name box..', type a name and click the 'Update gist' button at the bottom right.

:)


A command-line alternative is to clone the gist, add the file to the index, commit the change to the repository, and push the update to the remote repository:

git clone https://gist.github.com/…
git add …
git commit -m "…"
git push

In the interim, if the gist is altered using the site's ✍ Edit button—say to update the gist's description—simply pull in the change when next at the command-line:

git pull

In this complete example, the file JDBCPieTest.java was added to the original gist. Examine the log to see the effect:

git shortlog
trashgod (7):
  <none>
  Add JDBCPieTest.java.
  <none>
  Add JDBCXYTest.java.
  <none>
  Rename JDBCTest.java -> JDBCCategoryTest.java.
  Refactor JDBCPieTest.java.

https://developer.github.com/v3/gists/#edit-a-gist

Note: All files from the previous version of the gist are carried over by default if not included in the object. Deletes can be performed by including the filename with a null object.

^So just pass the files object containing your new file with the PATCH request and it will be added to the gist

Tags:

Gist