I accidentally published sensitive information instead of putting a sample image for two files in two commits a few months ago on our company's main website repo. I shared two pics at images/Example.jpg
and examples/Example.jpg
which ended up containing sensitive info instead of the actual example I wanted to push.
Now I'm wondering how can I substitute these with the correct Example.jpg and replace all the previous commits such that you can't ever "Browse the repository at this point in time" and be able to see that picture?
The information is in two files in two separate commits. If they weren't so far up the commit history, I'd probably just reset HEAD and repush, but that seems impossible now. Visually you can think of it like:
[AuthorX] commitLatest Latest commit
[AuthorY] commitTwoDaysAgo updated something
.....
.....
.....
[ ME ] commit2MonthsAgo sensitiveInfo1
.....
[ ME ] commit2MonthsAgo sensitiveInfo0
[AuthorZ] olderCommits --FINE FROM HERE--
.....
I want to keep the commit history exactly the same except that the two images in commits sensitiveInfo1
and sensitiveInfo0
have a different images/Example.jpg
. Is that possible?
I tried filter-branch
from here but it gave this warning:
WARNING: git-filter-branch has a glut of gotchas generating mangled history
rewrites. Hit Ctrl-C before proceeding to abort, then use an
alternative filtering tool such as 'git filter-repo'
(https://github.com/newren/git-filter-repo/) instead. See the
filter-branch manual page for more details; to squelch this warning,
set FILTER_BRANCH_SQUELCH_WARNING=1.
I'm worried I'll mess up the company's main repo if I use that. The documentation for git-filter-repo
is so confusing and convoluted. Like I'm worried it'll completely rewrite the authors or data or something. Or for example, we have lots of open branches, and I'm worried that it will mess up something there? Any suggestions on how to do this safely? I really appreciate this as I'm kinda panicking.
Thanks so much.