views:

24

answers:

1

Hi,

I've been trying really hard to remove a file with sensitive data from my git repository using this excellent page (among others): http://help.github.com/removing-sensitive-data/

the primary line being:

git filter-branch --index-filter 'git rm --cached \
    --ignore-unmatch FileWithSecrets.java' HEAD

However even when I follow the instructions including the pruning and garbage collection of objects the fact that I've rewritten the history does not seem to remove the file completely.

The point being I can still find the file's contents using git grep: git grep $(git rev-list --all)

....and it still shows up.

Am I missing something obvious or non-obvious? Why can I still "git grep" the contents?

I do see that the file is no longer in the changeset when I do a "git show" of the commit where it got added. But even so I can still grep it - like it's been removed from the branch history but is still floating out there?

Git is fun, cool and amazing but really can shake one's self confidence :)

thanks!! Brendan

+1  A: 

I didn't try this, but since the last argument to git filter-branch is defined as [--] [<rev-list options>...] and you're getting the sensitive info from the revs in git rev-list --all, this should work:

git filter-branch --index-filter 'git rm --cached \
--ignore-unmatch FileWithSecrets.java' -- --all
                                       ^^^^^^^^
al
Yup, providing HEAD as the argument as the OP did means that only HEAD is rewritten - not even the branch HEAD is pointing to!
Jefromi
Thanks so much for the answers - pointing out both the HEAD mistake and the --all argument. I did try the new command+cleanup and it still did not remove the file from "git grep" results.I'm wondering if the problem might have something to do with the fact that I have tagged several commits with "git tag" and those are being treated as separate branches. I tried checking each of these out individually and running the above filter-branch, but I can still grep the 'secret string'.I did try seeing if I could reproduce with a simple repo, but the commands work.
Brendan
Your annotated tags should also get rewritten with the --all argument.Did you run the cleanup steps mentioned in the github instructions you linked? `$ rm -rf .git/refs/original/` `$ git reflog expire --all` `$ git gc --aggressive --prune`
al