Navigate back to the homepage

Today I Learnt - Git Submodules

Nancy Chauhan
April 16th, 2020 · 1 min read

It often happens that while working on one project, you need to use another project from within it. For that, we can make use of git submodules.

Submodules are a reference to another repository withing a parent repository. You can make a submodule point to any arbitrary revision of the other repo.

Today I learned how messy git submodules could be! 😾

Using submodules needs many disciplines. Every developer using repo always need to update submodules using git submodule update —init —recursive. Failing to update can lead to very hard to debug and silent errors. And that’s not all if you forget to update the submodules, then git commits the old version of the submodule. This effectively undoes the submodule update done by another developer. And git log doesn’t even show such an update 😓.

Submodules need references to the URL that git should fetch. We all use SSH authentication in git. To make submodules experience frictionless, we point submodules using another SSH URL. When you start consuming this repo in CI such as Jenkins, which uses https to clone, everything breaks 😢 , so either you force your CI to clone ssh and set up its authentication or force your ci to pull everything in https, which is not possible in all scenarios. Now we are left with a decision to choose between frictionless CI or frictionless development experience. 😕

Also, there are many stories about submodules getting lost during merge conflicts, submodules not supported by some UI tools, etc. which makes them pure evil.

Some people say submodules are “Sobmodules.” 🤣

Originally Posted at https://todayilearnt.xyz/posts/nancy/git_submodules/

More articles from Nancy Chauhan

Monitoring Java Web Apps using Prometheus and Grafana

Monitoring an application’s health and metrics makes it possible to manage it in a better way and notice unoptimized behavior.

April 15th, 2020 · 3 min read

Summer, Code, and Hack!

This summer, I worked on developing continuous integration pipeline for hardware projects during GSoC 2019.

August 22nd, 2019 · 2 min read
© 2018–2022 Nancy Chauhan
Link to $https://twitter.com/_nancychauhanLink to $https://github.com/Nancy-ChauhanLink to $https://www.linkedin.com/in/nancy-chauhan/Link to $https://www.instagram.com/heyanancy/Link to $https://medium.com/@_nancychauhan