1

I have a project which has a repository. I have the root folder of the repo,

/A
  /A1
  /A2
/B
  /B1

I want to seperate the A folder into a different repository, then I want another repository, which looks exactly the same as the one described above, but with instead of folder A, I want folder A to be a submodule of the repository which I just created. So that A is an independent project, and the other repo depends on submodule A, but also contains B.

How should I do that? Or do I have to create a whole new project with losing all commits?

Thanks already!

Alexander Cogneau
  • 1,286
  • 4
  • 12
  • 25

1 Answers1

0

You can clone the repository and use git filter-branch to remove the history you don't want from both the repositories. After that, you can add A as a submodule to B.

Edit: After following the github guide, do

git filter-branch --tree-filter "rm -rf A" --prune-empty HEAD to remove history of A from B.

Edit: This SO question has a comprehensive answer.

Community
  • 1
  • 1
rohit89
  • 5,745
  • 2
  • 25
  • 42