How to delete a specific revision of a github gist?

Cyril N. picture Cyril N. · May 6, 2011 · Viewed 17k times · Source

I created a Gist on GitHub and I saw informations I don't want anyone to see. I updated the file since, but everybody can still access the old revision of the file.

Except deleting the Gist, is there a way to delete that particular revision definitely?

I saw that I'm not the only one having that kind of problem (Git: delete a single remote revision) but I didn't manage to remove the revision. The process indicated here seems to help remove some files. I want to remove the whole revision.

Answer

Tilman Vogel picture Tilman Vogel · May 6, 2011

Github has a help page about removing sensitive data:

http://help.github.com/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 <commit> as 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).