How it works...

When using the subtree strategy, Git finds out which subtree in your repository the branch you are trying to merge fits into. This is why we added the content of the lib_a repository with the read-tree command, to make sure we got the exact same SHA-1 ID for the lib_a directory in the super project as the root tree in the lib_a project. In the following example, the SHA-1 is found in the first command.

We can verify this by finding the SHA-1 of the lib_a tree in the super project in the commit that we merged the subproject with:

$ git log -1 | head -1 | awk '{print $2}'0f10e563c6824402d30380c9f8fbf87769e64e8a$ git ls-tree 0f10e563c6824402d30380c9f8fbf87769e64e8a 100644 blob 456a5df638694a699fff7a7ff31a496630b12d01 README.md ...

Get Git Version Control Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.