Mystic_Quest
Mystic_Quest

Reputation: 170

How to clean/untrack Git LFS files that have been deleted from my local repo?

I initially made a git repo and uploaded large files to git LFS. Now I want to clean it and upload only a necessary few files to git LFS so that I don't exceed the quota.

So what I did is:

Also tried git lfs prune but it seems to be keeping everything. enter image description here

Even though I commited after the deletions, all these large files seem to still keep getting referenced and uploaded on push to the new empty repo. Desired result is to only upload to LFS the few large files that have remained in the project.

Upvotes: 4

Views: 1380

Answers (1)

Gonzalo Matheu
Gonzalo Matheu

Reputation: 10064

I the lfs tracked files are in the git history at any point those will be pushed. Even if not are present in last commit.

So it very likely you will have to rewrite git commit history:

Either by rebase (git rebase --interactive <commit before files were include>) or if it is too old in git history using filter-branch

You could search which commits still refer to that file with: git log --all --full-history -- "*<files names were tracked with lfs>.*"

Upvotes: 2

Related Questions