newren / git-filter-repo

Quickly rewrite git repository history (filter-branch replacement)
Other
8.44k stars 706 forks source link

[Question] Lost all folders #593

Open BenGeba opened 2 months ago

BenGeba commented 2 months ago

I want to move a subfolder from an existing repository to a new repository.

The folder structure looks like this:

src/
  client/
  common/
  server/
    web/
      project1
      project2

If I now want to extract project 2, I have used the following command:

git filter-repo --subdirectory-filter Server/Web/Amagno.Server.Web.DocumentRecognition/

The history is still there, but when the script cleans up, everything is simply thrown away and only the .git folder is left in the main directory.

I would have thought that it would now look like this:

src/
  project2

Have I misunderstood something fundamental or am I doing something wrong?

newren commented 2 months ago

You haven't stated what the repository structure of the original repository was. I suspect that Server/Web/Amagno.Server.Web.DocumentRecognition/ was not a directory tracked within git; perhaps you gave a path relative to your current working directory, and you weren't in the toplevel directory of the repository? What is the output of git ls-tree -rlt HEAD | grep ' tree ' in your repository before doing the cloning?