Search code examples
gitgit-filter-repo

Deleted and force-pushed object still show up on other dev's machine


  1. Someone accidentally commited and pushed a number of large files
  2. I have deleted the files by using git-filter-repo that rewrites the history (like this answer suggests)
  3. The git-filter-repo --analyze has confirmed that the files are, in fact, removed
  4. I used git push --force to fore-push the rewritten history to the origin

So far so good

However

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?


Solution

  • 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 feature-branch:

    $ 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).