- Someone accidentally commited and pushed a number of large files
- I have deleted the files by using
git-filter-repothat rewrites the history (like this answer suggests)
git-filter-repo --analyzehas confirmed that the files are, in fact, removed
- I used
git push --forceto fore-push the rewritten history to the origin
So far so good
When the repo is pulled to other devs’ machines (using
git pull --rebase) the
git-filter-repo --analyze still shows those big deleted blobs/files (not shown on my machine though)
git gc and
git prune do not help.
What have I done wrong?
Fetch and reset hard
If a remote branch has changed and you want to match it exactly:
$ git fetch $ git reset —-hard origin/main
If there are local commits they wish to keep that’s also possible using git rebase onto – for example to keep commits on
$ git fetch $ git rebase --onto origin/main main feature-branch
Why didn’t rebasing just-work?
In the circumstances described in the question your colleagues have the unwanted files in their local clones – merging/rebasing the remote branch will not change that there are commits containing these unwanted files ( and any subsequent push will reintroduce those unwanted files to the remote).
Answered By – AD7six