Вопрос

I know there are sub trees and sub modules within GIT but i am still not sure which one would be the best option in my case.

So the situation is this:

  • I have a project with "lib1" and "lib2", project and repo are already there, i am not starting from scratch
  • I want to keep all the project in the same GIT repo for easier checkin/checkout and since i mainly work on that repo
  • Project is not open source but i would like to open source "lib2"
  • I will never work on "lib2" alone, only within the main project
  • I am not expecting contributions to lib2 so merging from its repo its a minor issue
  • Ideally i'd like this to be transparent to other devs working on this project (so when they commit/push they won't need to know that there is a subtree below)

So, the idea would be to be able to push "lib2" with its own history keeping all the rest of the project private. I know there are a lot of questions on this topic already but i wasnt able to find a clear answer.

Это было полезно?

Решение

You could leave the repository as it is and export this lib using:

git filter-branch --subdirectory-filer lib2

git help filer-branch says:

   --subdirectory-filter <directory>
       Only look at the history which touches the given subdirectory.
       The result will contain that directory (and only that) as its project root.

Developers of your project will not notice any change, because there is no change. - However updating that exported library would require you to run another filter-branch.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top