git extract directory from repository - commit history prior to renaming is missing

Viewed 265

I want to extract a directory from a repository, including all its commit history. The problem I'm having is that the end result, does not contain commit history prior to moving/renaming the files (which was done at some point).

Example:

  • I want to extract src/lib/features/TheLib from a project repository.

  • This directory 'theLib' used to be in a different location at some point, e.g. 'src/util/lib/TheLib'.

  • The main repository contains full history of changes made to the files, including changes before the lib was moved to a new location within the repo.

  • If I try to extract the directory into a new repository, I only have the commit history from the point after the files were moved/renamed.

I have tried this [0]:

$ git filter-branch --prune-empty --subdirectory-filter src/lib/features/TheLib master

and this [1]:

$ ./git-filter-repo --subdirectory-filter src/lib/features/TheLib

Both tools give me the same results. It almost works fine, except no commit history prior to renaming.

[0] https://docs.github.com/en/free-pro-team@latest/github/using-git/splitting-a-subfolder-out-into-a-new-repository

[1] https://github.com/newren/git-filter-repo/blob/main/Documentation/converting-from-filter-branch.md#cheat-sheet-conversion-of-examples-from-the-filter-branch-manpage

0 Answers
Related