user3124181
user3124181

Reputation: 863

GIT File Remains in History Even After Removed

I have a large file in git that was later removed. file_123.xlsx

I want to delete it from history as well due to its size, but can't seem to do so. I've followed instructions from many others that say the following:

git filter-branch --index-filter "git rm -r -rf --cached --ignore-unmatched file_123.xlsx" HEAD

Which shows the file getting removed

rm 'file_123.xlsx'
rewrite xxxxx (168/168)
Ref 'refs/heads/master' was rewritten

I then follow these steps for garbage collection

git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now

However, when I go to my objects folder, I can still find the file in the pack. I do this first to list the blob ids that are large.

git verify-pack -v packxxx.idx | sort -k 3 -n | tail -3

123abc blob xxx xxx xxx
456abc blob xxx xxx xxx
789abc blob xxx xxx xxx

I then look at the last one on the list

git rev-list --objects --all | grep 789abc

This reveals the file I tried to delete:

789abcfile_123.xlsx

And my git folder has not gone down in size at all. Am I missing something, or is this file simply not getting deleted?

Upvotes: 2

Views: 52

Answers (1)

phd
phd

Reputation: 94422

Your filter command is git filter-branch … HEAD but your list command is git rev-list … --all. That is, you filtered one branch (master) but searched the file in all branches.

Filter all other branches too:

git filter-branch --index-filter "git rm -r -rf --cached --ignore-unmatched file_123.xlsx" -- --all

Upvotes: 2

Related Questions