Search code examples
gitgit-submodulesgit-subtree

Is git-subtree appropriate for me?


I have a 3rd party library included in my project. It is important that the "subproject" code should be included in the main/parent one, because the objective is when other people makes git pull, they could will download the code with no extra-effort (or minimal).

But I want the possibility to download updates from the library own repo.

Previously, that library was downloaded directly into his directory and updates were managing by commits in the main project.

Now I'm thinking in use git-subtree or git-submodule. Is git-subtree are useful for that purpose. Is git-submodule better?


Solution

  • Git subtree.

    • Easy for others to get.
    • Avoids complications if you DO want to make changes to the library.
    • Use the squash option to avoid pulling in massive histories when merging the library.
    • You can merge the library, using the git subtree command, and no one else needs to have support for the command to access and use your repository.
    • Changes made in your repository inadvertently to the library are no problem, and simply to split out if you want to contribute them.