Git Tutorial Video
For a visual explanation of what a submodule is—and how submodules work in GitKraken—watch this short video. It’s our latest Git tutorial video in our Learning Git series!
What is a submodule?
A submodule is like a Git repository inside another Git repository. They’re useful for splitting work.
For example, say we are building an app that needs a billing system. The main project team assigns a few team members to the billing project, while the rest of the team works on the main project. Because the billing system is subordinate to the main project, we decide to make the billing system a submodule within our main project.
So, how do the changes from the submodule get into the main project?
When you set this billing project as a submodule, you are pointing your project to a specific commit in the submodule. This tells Git to add all files in this submodule’s commit to the main project. However, if you make changes to your submodule repository, the changes will not get incorporated until you manually change the pointer commit in the submodule repo.
Basically, you can think of submodules as child repositories of one parent repository. They’re quite useful for working in parallel.
How submodules work in GitKraken
If you’re using GitKraken—our Git GUI client for Windows, Mac, and Linux—open up the app and navigate to the lower left corner to access submodules. If your repo already has submodules, you can click to edit the Remote URL, the Path, or view the Current Revision. You can also open your submodule’s repository inside of GitKraken, and make any additional changes.
When you exit the submodule, GitKraken will detect the update and you can select Commit Changes to incorporate the changes into the parent repository.
If you need to create a new submodule for your existing repository, click the + icon from the submodules pane to enter the remote URL and the repo path. You will see the update to your
.gitmodules file in your WIP node, and once you commit the changes, your submodule will be ready!
Stay on the cutting edge of software development by getting innovative tips, trends and stories delivered to your inbox every month!