0

There is some sensitive information that was committed to a repository about a month ago that I'd like to completely remove any trace of.

I'm adept at using git rebase and know I can use this to change the commit, and answers like How to delete a 'git commit' from LOG, like it had never existed show how to just delete a commit using git rebase.

However, the pre-rebased hash of the offending commit is still findable using

git log -p $BAD_SHA

So, even though the commit no longer appears under git log, with the above command someone can still see the sensitive information even though it has been "deleted" using rebase.

Is there a way to essentially completely remove a SHA after it has been rebased, so that it no longer shows up using git log -p $BAD_SHA?


Addendum: I have tried git gc --prune=all --aggressive after rebasing, and this does not solve the problem. There is no branch either on the local or remote repository that still references the bad hash I want to get rid of.

Community
  • 1
  • 1
Manmaru
  • 578
  • 3
  • 8

2 Answers2

1

If the commit is not viewable on any existing branch, garbage collection should take care of it.

git gc --prune=all
  • I've tried `git gc --prune=all` and `git gc --prune=all --aggressive`, but the offending SHA still appears in `git log -p $BAD_SHA`. There is only one branch in this entire repository, both on local and on remote. – Manmaru Aug 11 '16 at 20:13
  • See if this finds any references to it: `git describe --all --contains $BAD_SHA` –  Aug 11 '16 at 20:14
  • The reflogs also point to commits, so that might have prevented gc from cleaning it up as well. – David Neiss Aug 11 '16 at 21:56
  • Tags also point to commits, so again, unless the tag is deleted, their pointed to commits will hang around as well. – David Neiss Aug 13 '16 at 16:07
0

Turns out, after performing garbage collection with git gc --prune=all --aggressive, I also needed to completely remove the repository locally and then re-clone it. Now the offending commit does not show up in git log -p $BAD_SHA.

Manmaru
  • 578
  • 3
  • 8