FluidMotion » NaibsPages » News » Git: Subtree vs Submodule
Git: Subtree vs Submodule
Say you are using git as your vcs of choice and say you want to include another git repo into your project what can you do?
You can do one of three things
- Statically copy over all the files
This is one possible solution and if you only want certain files from a certain date and no other then sure use this method.
- git subtree's
This is akin to merging in another project into your project with the ability to pull from upstream if needs be.
- git submodules
Git's submodule support allows a repository to contain, as a subdirectory, a checkout of an external project.
So the question is: What do you want todo with an upstream project with respect to associating it with your project?
ignoring the 1st option (statically copying over needed files) since this doesn't really have any bearing on source control.
subtree's in git are more akin to merging in another project into your project (within a subfolder) with some infomation with regards to the remote address.$ git remote add -f SubA git://URL:upstreamA.git
$ git merge -s ours --no-commit SubA/master $ git read-tree --prefix=SubA-dir/ -u SubA/master $ git commit -m "subtree merged"
The first line creates and fetches the remote. The second line initiates a merge, but stops before committing it. The third line reads SubA/master into the subdirectory "subA-dir", at which point all that remains is committing the completed merge.
git pull -s subtree naib_sub master
= W.I.P =