Has this ever happened to you?
cue video of someone accidentally committing
super-secret-private-stuff.json
Time to blow away the entire project and start over right?
With git-obliterate
, you can make it seem like the file has never existed in the project's history!
First, read this because I'm mostly just scripting a lot of what they say here: https://help.github.com/articles/remove-sensitive-data
Download the file, chmod +x
it, and copy it to /usr/local/bin
(or somewhere else in your PATH
). Then you can do git obliterate <file>
and it will wipe it from history. Singing Cher's “If I Could Turn Back Time” is optional. You will then have to git push --force
to update your remote.
After that's done, you'll need to force update your remotes with git push --force
, making sure to do all the branches and tags and everything that the file might have been in – if you're lucky, you will have caught it early and hopefully that should just be master
.
curl -O https://gist.githubusercontent.com/brianloveswords/7545299/raw/6128cb79b624d915bfc1942177a3508fd47efbfe/git-obliterate && chmod +x git-obliterate && sudo mv git-obliterate /usr/local/bin
Thanks so much for writing this!