I have a pushed file with an history of sensitive data.
I'd like to clear the repository from all the file commits history, and leave only the current one, which is clean of sensitive data.
How can I do it (using git bash or GitHub desktop\web)?
I have a pushed file with an history of sensitive data.
I'd like to clear the repository from all the file commits history, and leave only the current one, which is clean of sensitive data.
How can I do it (using git bash or GitHub desktop\web)?
Find a version of that file you're willing to keep, say the latest master
copy's clean:
safeversion=`git rev-parse master:path/to/file`
Filter history removing any version of that file that's not the safe one:
git filter-branch \
--setup safeversion=`git rev-parse master:path/to/file` \
--index-filter '
if thisversion=`git rev-parse -q --verify $GIT_COMMIT:path/to/file` &&
[[ $thisversion != $safeversion ]]
then git update-index --force-remove path/to/file
fi
' -- --all