Search code examples
gitgithubrevisiongist

How can I delete a specific revision of a github gist?


I created a Gist on GitHub and I saw information 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.


Solution

  • 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).