1

Let's assume repository of my project has a folder like:

test/EFG

which is renamed from:

test/ABC

Now I'm trying to split EFG folder into new repository. I'm using following command:

git filter-branch --prune-empty --subdirectory-filter test/EFG master

It works great, but there is a big downside. Using this command, It only transfer history after renaming to EFG folder. Is there anyway to keep history before renaming to EFG too (history of folder when it was named ABC)?

Afshin
  • 8,839
  • 1
  • 18
  • 53

1 Answers1

-2
git subtree split

.... this should be able to do, what you want. The git documentation says the following about it:

Extract a new, synthetic project history from the history of the subtree. The new history includes only the commits (including merges) that affected prefix, and each of those commits now has the contents of at the root of the project instead of in a subdirectory. Thus, the newly created history is suitable for export as a separate git repository.

Please refer to https://lostechies.com/johnteague/2014/04/04/using-git-subtrees-to-split-a-repository/ for a more detailed description of how to use it.

salchint
  • 371
  • 3
  • 10
  • For `git subtree` in this case, https://stackoverflow.com/questions/26304941/follow-renames-when-performing-git-subtree-split may be a better reference. – Joe Dec 09 '18 at 12:10