6

How do I move files and folders in my master repo into an existing submodule? Can I preserve history somehow?

MKaras
  • 2,063
  • 2
  • 20
  • 35
  • 1
    Possible duplicate of [Create a submodule repository from a folder and keep its git commit history](http://stackoverflow.com/questions/17413493/create-a-submodule-repository-from-a-folder-and-keep-its-git-commit-history) – CarmeloS Dec 01 '15 at 08:36

1 Answers1

1

Assuming you have only a single branch in you repos: take your submodule repo, add your master repo as a second remote, fetch the history and remove everything but the chosen files. merge the result to you master repository branch.

Here "remove" could mean two things. Either a simple git rm which will create a clean HEAD but the deleted files will remain in history. Or a git filter-branch which is able to create a new history consisting only of the chosen files.

At your master repository you have basically the same options. Either use git rm to delete the moved files in HEAD or use git filter-branch to remove them from the whole history.

michas
  • 25,361
  • 15
  • 76
  • 121