Search code examples
gitgit-filter-repo

Where did all my files go after git filter-repo


I fear I am in a load of trouble! I was trying to remove a folder called notebooks from my repo's history.

I used git filter-repo --path notebooks --force.

This seems to have deleted all of the files that had been in the index in my repo, not just from notebooks path; what happened? For the majority of these files, I can just restore from the remote, but the problem is my local branch had not push some important files to the remote before I did this.

Is there a way to recover the files that got deleted??


Solution

  • Since you used the --force option there is no way to recover your files from this repository (see documentation of filter-repo --force):

    Since filter-repo does irreversible rewriting of history, it is important to avoid making changes to a repo for which the user doesn’t have a good backup.

    It is an irreversible operation, especially since it by default ends with an immediate pruning of reflogs and old objects

    So your only chance is a backup, i.e. you pushed somewhere or someone pulled from you.