1

I have a git project which contains some files copied from another git project. Now I want to convert those files into a git submodule. Can I do that without losing the history of the changes I already did? thanks!

user1709181
  • 105
  • 1
  • 1
  • 7
  • 1
    You should instead, first add the second repo as a submodule, then you make your own commits on the submodule which can include deleting files – Parham Feb 08 '13 at 23:29
  • I believe the answer to your question is already covered here: http://stackoverflow.com/questions/3910412/split-large-git-repository-into-many-smaller-ones. – artyom Feb 09 '13 at 16:00

1 Answers1

0

Make a copy of your repository, eliminate everything outside future submodule using git filter-branch. So you have only commits describing what happened in that subdirectory and directory hiearchy looks exactly same as in future submodule.

Then add this new repository as a remote to upstream repository and do a merge. Git will say something about no common ancestor, but it should work.

After all this delete the subdirectory in your project and put submodule on it's place (in one commit).

Josef Kufner
  • 2,851
  • 22
  • 28