Github has a help page about removing sensitive data:
As gists are just git repositories, you should be able to locally clone your gist, do the clean-up there and do a forced push to overwrite the github version with the cleaned repo.
Yes, after thinking about it: If
<commit> is the commit you want to “remove”, do
git rebase -i <commit>^
mark the line for
edit, save and quit.
git will set up the working directory to the state after you comitted
<commit>. Fix the file, use
git add and
git commit --amend to fix the commit. Then do
git rebase --continue. If the only thing, the next commit did, was to remove the sensitive data, it will probably be automatically dropped because it doesn’t contain any changes after the now-amended commit.
Then, do a
git push -f to force the update (because it is now non-fast-forward, meaning it changes already published git history).