1

I committed a few times to my Github, and realized that I had some sensitive information on one of the earlier commits. I've removed it since then in my most recent commits, but if someone were to look at my commit history, they would be able to see the sensitive info. Is there any way I can get Github to forget the commit, or somehow make it so people cannot look at that particular commit?

riley lyman
  • 317
  • 1
  • 11
  • 1
    This is tough to do. Even if you rewrite history and kill that commit, or just reword the comment, there is still a chance that some other branch could be referring to that original commit, or GitHub may still have it cached. Your best bet might be to rewrite the commit, assuming you can do that. But take this as a lesson that once the cat is out of the bag, it's very hard to get it to go back in. – Tim Biegeleisen Aug 03 '18 at 06:05
  • 1
    There is, but there are no guarantees that someone hasn't read it already. Best to just generate new sensitive information to replace it, and don't do it again. [How can I remove a commit on Github?](https://stackoverflow.com/questions/448919/how-can-i-remove-a-commit-on-github), [Delete commits from a branch in Git](https://stackoverflow.com/questions/1338728/delete-commits-from-a-branch-in-git) – Amadan Aug 03 '18 at 06:06

1 Answers1

0

You should rewrite your history using git rebase -i and then use git push --force to override the distant branch with your local one.

Orpheo
  • 386
  • 1
  • 6
  • 15