Figuring out the cause of a GitHub personal access token throwing “remote: Permission to write to gist denied.”
Posted by jpluimers on 2024/01/17
Last week I mentioned
My forking was needed because of [Wayback/Archive] Jeroen Wiert Pluimers on Twitter: “Need @github help: Personal Access Token fails on … with a “The requested URL returned error: 403″, but works fine on … Why is that? (I own both repositories)”
- fails for [Wayback/Archive] gist: Script to rename a virtual machine in ESXi 6:
Username for 'https://gist.github.com': jpluimers Password for 'https://jpluimers@gist.github.com': remote: Permission to write to gist denied. fatal: unable to access 'https://gist.github.com/fcc601dd41ac89f601a5174be92c841c.git/': The requested URL returned error: 403- works for [Wayback/Archive] jpluimers/vm-rename: Script to rename a virtual machine in ESXi 6; fork from https://gist.github.com/jpluimers/fcc601dd41ac89f601a5174be92c841c:
Counting objects: 3, done. Delta compression using up to 8 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 1.98 KiB | 1.98 MiB/s, done. Total 3 (delta 0), reused 0 (delta 0) To https://github.com/jpluimers/vm-rename.git e3683fb..391d638 master -> master
So after the stop gap measure I described in the blog post Fork Gist to Repo on GitHub – Stack Overflow, I did not stop.
I searched for [Wayback/Archive] “remote: Permission to write to gist denied.” – Google Search which only gave one result:
[Wayback/Archive] can’t push to a gist – permission denied message – GitHub Help / How to use Git and GitHub – GitHub Community. It was of no use as it mentioned you could just a plain password login (which fails with the same error), or not use .netrc (which I did not use).
So I added more search terms, which not gave less results, but (since the quoted exact match would make it return zero results) returned more results.
Now [Wayback/Archive] “remote: Permission to write to gist denied.” even with personal access token – Google Search gave me these (which I filtered so I could explain a few):
- [Wayback/Archive] git – Github remote permission denied – Stack Overflow: explaining a similar problem at the main github.com site when switching accounts (which I didn’t) and can be solved by removing cached credentials (with examples on MacOS on Windows)
- The same GitHub Community post mentioned above
- [Wayback/Archive] The requested URL returned error: 403 Forbidden · Issue #39 · trilbymedia/grav-plugin-git-sync which has a solution if you fold out the hidden comments; the folded out comment is [Wayback/Archive] The requested URL returned error: 403 Forbidden · Issue #39 · trilbymedia/grav-plugin-git-sync: comment 772377481 by [Wayback/Archive] caprica-Six (Pepa):
I was getting the same “403 error. Permission to write to gist denied”, when trying to clone a gist repo with https.
Repo format is: https://github.com//.git
Here’s how I fixed it:
- Created Personal Access Token, as per docs.
- Ticked – gist – Create gists.
- Login – username, which is user, not email (as mentioned above)
- Password – this is the Access token – paste
Now all is working fine. I am able to commit.

So I looked at the token in github.com/settings/tokens and indeed [Wayback/Archive] Jeroen Wiert Pluimers on Twitter: “No help from @github, but I have figured it out. Screenshot 1 is what the token is allowed to do. The unchecked “gist=Create gists” is not just for creating gists, but also to any other write operation to gists. So I recreated the token with “gist=Create gists”: now it works!”
Now it works:
# git push origin Username for 'https://gist.github.com': jpluimers Password for 'https://jpluimers@gist.github.com': Counting objects: 3, done. Delta compression using up to 8 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 1.98 KiB | 1.98 MiB/s, done. Total 3 (delta 0), reused 0 (delta 0) To https://gist.github.com/fcc601dd41ac89f601a5174be92c841c.git e3683fb..391d638 master -> master
–jeroen











Leave a comment