dev-resources.site
for different kinds of informations.
Have you ever used `git submodules`?
I am currently contributing to an open-source project called Grida, specifically working on building a canvas with a figma like interface. In order to setup the Grida’s development environment, you need to use git submodules
. I didn’t know this, got a hint from the authors at Grida and I decided to share what is a git submodules
command in this article.
Git Submodules
I am quoting below what I found in the git-scm site.
It often happens that while working on one project, you need to use another project from within it. Perhaps it’s a library that a third party developed or that you’re developing separately and using in multiple parent projects. A common issue arises in these scenarios: you want to be able to treat the two projects as separate yet still be able to use one from within the other.
Here’s an example. Suppose you’re developing a website and creating Atom feeds. Instead of writing your own Atom-generating code, you decide to use a library. You’re likely to have to either include this code from a shared library like a CPAN install or Ruby gem, or copy the source code into your own project tree. The issue with including the library is that it’s difficult to customize the library in any way and often more difficult to deploy it, because you need to make sure every client has that library available. The issue with copying the code into your own project is that any custom changes you make are difficult to merge when upstream changes become available.
Git addresses this issue using submodules. Submodules allow you to keep a Git repository as a subdirectory of another Git repository. This lets you clone another repository into your project and keep your commits separate
This documentation provides information on different scenarios such as:
Starting with Submodules
Cloning a Project with Submodules and so on…
but what worked for me in setting up the Grida development environment is this — Cloning a Project with Submodules
I study large open-source projects and provide insights, give my repository a star.
I initially tried to run the pnpm install
, but I kept the getting errors about missing package.
I used the command to below to properly clone the Grida source code in my machine:
git clone --recurse-submodules https://github.com/gridaco/grida
This command is going to clone the submodules that this project is dependent on and these submodules are different repositories themselves.
Executing this command only gets you all the submodules required, you would still need to run pnpm install
and to start the development environment, run pnpm run dev
I highly recommend reading more about submodules.
About me:
Hey, my name is Ramu Narasinga. I study large open-source projects and create content about their codebase architecture and best practices, sharing it through articles, videos.
I am open to work on interesting projects. Send me an email at [email protected]
My Github — https://github.com/ramu-narasinga
My website — https://ramunarasinga.com
My Youtube channel — https://www.youtube.com/@thinkthroo
Learning platform — https://thinkthroo.com
Codebase Architecture — https://app.thinkthroo.com/architecture
Best practices — https://app.thinkthroo.com/best-practices
Production-grade projects — https://app.thinkthroo.com/production-grade-projects
References:
Featured ones: