This is just a short post and the title says it all … I’ve wanted add submodules to a Git repository but you get an error if you try.  So how do you add a submodule to your root folder in your Git project?  Easy - Git Subtree Merge is what you need.

Add your 2nd Git Project as a Remote

Actually, you start by adding a git remote with the source being the git project you want to pull in.

Git Remote SourceTree

The you do a pull from your Remote … and merge / diff any of the files

Gite Remote Merge

Now you have your second project added in the root of your main project 🙂   So .. go to your second project .. make a change and commit and push it  … then go back to your first project and you’ll see the remote has an update 🙂






Git Subtree Merge on Git SCM

Tags: Git, Submodule

Read more from my blog for an introduction and quick tips on developing in Hugo or UCTD.

Meet the author

Photo for Damien Saunders
Damien Saunders
An experienced management consultant and business leader interested in digital transformation, product centred design and scaled agile. If I'm not writing about living with UCTD (an autoimmune disease), I'm probably listening to music, reading a book or learning more about wine.