Reputation: 4288
I have a framework I am building to make some common functions (database connection) easier and would like to use it in another project. I could always just copy and paste it, but I am working on it and expanding it constantly. It would be much easier to just have it copy its updated self over whenever I do a commit in my Git repo.
Could I use Git to automatically update the framework in my other project or will I have to find another solution?
Upvotes: 2
Views: 756
Reputation: 41383
Use either git subtrees or git submodules.
Last time I've checked, submodules had some major issues (but I've heard that they were improved a bit in recent versions). See here for details: Git submodules workflow
In short:
Subtrees are regular Git branches, merged with special merge strategy, which puts all their files into a subdirectory of the host repository working copy. Aside of the merge strategy (which matters only when merge commit is created), Git "subtree" is a perfectly normal Git branch.
Pros:
-s subtree
command line option (see here for the full workflow). You need to remember about subtree only when you do the subtree pull.Cons:
Submodules are Git repositories inside the host repository.
Pros:
Cons:
Disclaimer: I'm biased against submodules. Try and see for yourself, what approach is better for your workflow.
Upvotes: 5
Reputation: 101156
git-submodules.
You will have a few issues with updating in different places, but it should work out.
Upvotes: 1