@ivan-zuzak 's answer is obsolete now that the GitHub API supports deleting files by passing null sha's.
To delete a file you would create a tree in Javascript with octokit like so:
await octokit.request('POST /repos/{owner}/{repo}/git/trees', {
owner: 'octocat',
repo: 'hello-world',
tree: [
{
path: 'path/to/file-that-will-be-deleted.py',
mode: '100644',
type: 'blob',
sha: null,
}
],
base_tree: 'sha'
})
The base_tree should contain the SHA1 of an existing Git tree object you want to delete the file from.
After that everything Ivan said still holds true, so you should construct a new commit that links to this new tree, and bump the ref to point to this new commit.