Search code examples
gitrepositorygit-submodulesgit-subtreeatlassian-sourcetree

is git submodules what I need?


I have two repositories for two websites, but those two websites share the same framework.

I wanted to make a dedicated repository for the framework itself but I'm not sure how would that work.

What I currently do is that I develop the framework within website1 and then copy it to website2 each time I add new features. As you can see it's not very effective...

I would like a separate repository for the framework, but I still need it to be within one of the two websites so I can keep working on it. The most important part is that I need to be able to deploy it to the other website in a simple way

What is the best solution for me? How can this be achieved?

PS: I'm using SourceTree with Bitbucket quit intensively for the past months so I'm fairly familiar with git, but I have never used the command line.


Solution

  • As long as your framework is limited to a subdirectory of your website, then yes, you can consider your framework a submodule of your website repo, which acts as a "parent" repo.

    SourceTree supports submodules (since 1.3), and if your framework is managed in its own repo, you can add it to your website repo.
    See "Using submodules and subrepositories"

    add submodule in SourceTree