Deleting or renaming files in a multi-file Gist using Github API

The docs at Gists - GitHub Docs mention that PATCH method can be used for update or delete a gist file and rename gist files.

  • How do I express deleting a file inside a Gist? Should I specify content : null?

  • How do I express renaming a file?

How do I express deleting a file inside a Gist?

Delete a file by setting content to an empty string ("").

{
  "files": {
    "deleteme.md": {
      "content": ""
    }
  }
}

or not setting any properties.

{
  "files": {
    "deleteme.md": {}
  }
}

How do I express renaming a file?

Rename a file by setting the filename property.

{
  "files": {
    "renameme.md": {
      "filename": "renamed.md"
    }
  }
}

source: Cannot delete gist file with filename: null · Issue #19 · octokit/rest.js · GitHub

1 Like