I'm trying to remove a file which has sensitive data using this GitHub procedure.
However, this doesn't work for my specific repo. When I run:
git filter-branch --index-filter 'git rm --cached --ignore-unmatch some_file.json' \
--prune-empty --tag-name-filter cat -- --all
It completes with:
Rewrite 73f9cce9ab282cec272022314f361c1cd48955a7 (418/418)
WARNING: Ref 'refs/heads/master' is unchanged
WARNING: Ref 'refs/remotes/origin/blah' is unchanged
WARNING: Ref 'refs/remotes/origin/blah2' is unchanged
WARNING: Ref 'refs/remotes/origin/blah3' is unchanged
WARNING: Ref 'refs/remotes/origin/blah4' is unchanged
WARNING: Ref 'refs/remotes/origin/master' is unchanged
But nothing has changed. When I do
git push origin master --force
it says
Everything up-to-date
Does anyone know what I'm doing wrong?
If you commit sensitive data, such as a password or SSH key into a Git repository, you can remove it from the history. To entirely remove unwanted files from a repository's history you can use either the git filter-repo tool or the BFG Repo-Cleaner open source tool.
The easiest way to delete a file in your Git repository is to execute the “git rm” command and to specify the file to be deleted. Note that by using the “git rm” command, the file will also be deleted from the filesystem.
By deleting line of the commit or writing drop instead of pick, you can remove the commit from history. Thus, we deleted a commit locally. To remove it from remote repository, we should push our changes to remote. The + sign before the name of the branch you are pushing, this tells git to force the push.
Per discussion in comments, use the complete path of the file. The current version of the command is excising some_file.json
in the top level repo directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With