Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

removing file from git history doesn't work

Tags:

git

github

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?

like image 233
przygode Avatar asked Aug 27 '12 21:08

przygode


People also ask

Can you remove a file from Git history?

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.

How do I force delete a file in Git?

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.

How do I remove a commit from git history?

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.


1 Answers

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.

like image 56
Christopher Avatar answered Oct 19 '22 09:10

Christopher