Search code examples
gitbundlesubdirectory

git-bundle only some of the files in my repository


I have a library that I wrote for my app but now want to use it in all apps my company is going to write. The app and library both live in a git repository (repository A) with history that I really would like to preserve. The library sits in it's own subfolder.

I also have a second repository (repository B) that contains some other shared code - this is used as a git-submodule in apps that we write.

I would like to take the libraries subfolder from repository A and place it into repository B without losing it's history.

I've looked at git-bundle but don't seem to be able to specify files, only branches.

I've also looked at copying the repository and removing the files I don't want (like this) but the libraries files started out with different names and in different folders so I'm just not sure how that would work.

Does anyone have any ideas of the best way that this could be done?


Solution

  • You're looking for git filter-branch. See this question and answer (be sure to note the additional section marked 'edit', too).