I've been looking into Git submodules to make a "Git project inside a Git project", but I've run into an issue that tells me submodules might not be the right solution.
Let me explain what I am looking to do:
Currently I have a single project with multiple branches (master and development) and a library that I would like to separate into it's own Git project (so it can be developed independently and with it's own commit history). Specifically I also want to be able to:
- Commit and push changes in a separate clone of the library project which are not updated in the superproject until explicitly asked for.
- Use library master branch when on superproject master branch.
- Use library development branch when on superproject development branch.
It would also be nice (but not required) to be able to:
- Commit and push changes to the library project from within the superproject.
As far as I'm aware #1 and #4 are supported by Git submodules (even though #4 requires a few extra checks to make sure you're on the right branch). #2 and #3 not so much.
I've looked at Differences between git submodule and subtree and Vendor Branches in Git, but neither seem to offer exactly the functionality I'm asking for - is it possible to implement with Git? Is it possible without a lot of extra moving/renaming/checking out directories?