I'm trying to remotely update an existing Github gist through Git bash, and I cannot find a way to upload a file's contents without manually declaring the contents inside of the command.
My goal is to take a file I have on my PC, and upload its contents to update a pre-existing Gist (the Gist ID which is mentioned in the latter text).
Here is an example Gist ID in the hope that it helps: 'c7alSToGZjxiMveTa2e6bzVvXJRqS09D'. For the sake of this discussion, the exact name of the file I am trying to upload is 'testingFile.txt', located at the file path 'C:\Users\username\Desktop', with the Gist file display name of 'monkey.txt'.
How would I make the "curl PATCH" command be able to execute such an upload/update procedure? I've tried the following code curl -d '{"files":{"monkey.txt":{"content":"$chung"}}}' -u username:accessToken -X PATCH https://api.github.com/gists/{gist_id}
, where $chung
was set equal to the file contents of "testingFile.txt". This exact code would just end up uploading the text "$chung" to the gist, instead of the variable's actual contents (which for this example, is ["WelcomeToTheJungle", "AmazonRainforest", "Brazil"]
. Any suggestions on how to do this are welcome, cheers!
EDIT: Github's API for this is- https://docs.github.com/en/rest/reference/gists#update-a-gist