Git, GitHub & Version Control
Table of content:
- What Is GitHub?
- Git And GitHub- A Comparison
- How To Use GitHub?
- Components Of GitHub
- GitHub For Developers
- Tips To Create Your GitHub Portfolio
- Who Uses GitHub?
- Conclusion
- Frequently Asked Questions
- How Well Do You Know GitHub? Take A Quiz!
Table of content:
- What Is Git? Basics
- How Git Works?
- The Git Lifecycle
- About The Git Architecture
- The Different Types Of Git Workflows
- Common Functions Of Git
- Think You Understand Git? Prove It!
Table of content:
- What Is Git?
- What Is GitHub?
- Git Vs. GitHub (Difference Comparison Table)
- Git vs.GitHub: Differences Explained
- Git Vs. GitHub: The Similarities
- How To Integrate Git & GitHub?
- Common Git Commands to Know
- Conclusion
- Frequently Asked Questions
- Git vs. GitHub Quiz – Let’s See What You Know!
Table of content:
- What Is Git?
- Git Commands: Working With Local Repositories
- Git Commands: Working With Remote Repositories
- Branch- Git Commands
- Git Checkout Commands
- Merge- Git Commands
- Clone- Git Commands
- Commit- Git Commands
- Config- Git Commands
- Pull- Git Commands
- Push- Git Commands
- Rebase- Git Commands
- Stash- Git Commands
- Remote- Git Commands
- Some Advanced Git Commands
- Conclusion
- Frequently Asked Questions (FAQs)
- Know Your Git Commands? Let’s Test That!
Table of content:
- What Are Git Submodules?
- How Git Submodules Work?
- How To Add Git Submodule?
- How To Remove Git Submodule?
- Pulling In Upstream Changes From The Submodule Remote
- Git Submodule Commands
- Uses Of Git Submodules
- Mastered Git Submodules? Test Yourself!
Table of content:
- What Is Branch In Git?
- Why Are Git Branches Essential?
- How To Create A New Git Branch?
- Managing Git Branches
- Merging Git Branches
- How To Delete A Git Branch?
- Git Branch: Commands
- Git Branching Quiz – Test Yourself!
Table of content:
- Prerequisites For Git Create Branch Process
- How To Create A New Branch In Git?
- Branch Naming Conventions | Git Create Branch
- Different Ways Of Creating New Git Branch
- Git Create Branch In Visual Studio
- How To Delete A Git Branch?
- Conclusion
- Git Create Branch Quiz– How Well Do You Know It?
- Frequently Asked Questions
Table of content:
- How To Switch A Branch In Git? | Solutions To Git Problems
- Switching Branches In Git Using Git Checkout Commands
- What Is The Detached HEAD State?
- Switching Branches In Git Using The Git Switch Commands
- Switching Branches In Git Using GitKraken
- Difference Between Git Checkout & Git Reset
- Difference Between Git Checkout & Git Restore
- Difference Between Git Checkout & Git Clone
- Conclusion
- Frequently Asked Questions
- How Well Do You Switch Git Branches? Take A Quiz
Table of content:
- What Is A Git Repository?
- What Are Git Branches?
- Naming Convention For Git Branches
- Why Is Name Important?
- How To Rename A Branch In Git?
- How To Rename Local Git Branch?
- How To Rename Remote Git Branch?
- How To Rename A Git Branch Locally In Command Line?
- How To Rename A Branch In Github?
- Conclusion
- Frequently Asked Questions
- Git Branch Renaming Quiz– Ready for the Challenge?
Table of content:
- What Branches Are In Git?
- Git Delete Branch: The Fundamentals
- When To Delete Branches?
- What Happens When A Git Branch Is Deleted?
- The Command For Creating A New Branch
- How To Git Delete A Local Branch?
- How To Git Delete A Remote Branch?
- How To Delete A Branch On GitHub?
- Remove Vs. Local Git Branch Delete
- Git Push & Delete Remote Branch
- What Are Tracking Branches And How To Delete Them?
- Can I Recover A Deleted Branch in Git?
- Conclusion
- Frequently Asked Questions
- Ready To Test Your Git Branch Skills? Take A Quiz
Table of content:
- What Is Git Rebase? What Does It Do In Git?
- How Git Rebase Works?
- Git Rebase Vs. Git Merge
- Git Rebase Configuration
- Creating Master & Feature Branches
- Merge Strategies In Git Rebase
- Git Rebase Examples
- Git Rebase Commands
- Splitting Commits In Git Rebase
- Git Rebase Options
- Labelling Conflicts Markers
- Rebasing Commits Against A Branch
- How To Recover From Upstream Git Rebase?
- Best Practices For Using Git Rebase
- Git Rebase Quiz – Ready to Test Yourself?
Table of content:
- What Is Merge In Git?
- How Git Merge Works?
- Essential Commands To Perform Merge In Git
- Steps To Merge A Branch In Git
- Git Merge Conflict
- Types Of Git Merge Conflicts
- How To Resolve Merge Conflicts?
- Git Commands To Resolve Conflicts
- Conclusion
- Caught Up On The Basics? Let’s Test Your Skills!
- Frequently Asked Questions
Table of content:
- What Is Git Rebase?
- What Is Git Merge?
- The Working Of Git Rebase Vs. Git Merge
- Git Rebase Vs. Git Merge | The Differences
- Git Merge Vs. Rebase | Differences Explained
- Git Rebase & Git Merge Similarities
- Advantages & Disadvantages Of Git Merge
- Advantages & Disadvantages Of Git Rebase
- How Do You Use Git Rebase & Git Merge Together?
- Git Rebase vs. Merge. Which Is Better & When to Use?
- Conclusion
- Frequently Asked Questions
- Git Rebase vs Merge Quiz – Can You Choose Right?
Table of content:
- Introduction To Git stash
- Importance Of Git Stash
- How To Use Git Stash Command?
- Git Stash Commands
- Git Stash Options
- Git Stash vs. Git Commit
- Git Stash vs. Git Reset
- Git Stash vs. Git Stage
- Best Uses/ Practices Of Git Stash
- Conclusion
- Frequently Asked Questions
- Git Stash Quiz – Are You Ready?
Table of content:
- What Is Git Cherry Pick?
- When To Use Git Cherry Pick Command?
- How To Use Git Cherry Pick?
- Git Cherry Pick For Multiple Commits
- Undo Changes & Restore Lost Commits With Git Cherry Pick
- Git Cherry Pick Example (Command Line)
- What Happens When We Cherry Pick A Git Commit?
- Sequencer Subcommands In Git Cherry-Pick
- Does Git Cherry Pick Create A New Commit?
- Git Cherry Pick Conflict
- Git Cherry Pick vs. Git Rebase
- Is Git Cherry Pick The Same As Merge?
- Advantages and Disadvantages Of Git Cherry Pick
- Hidden Git Cherry Pick Commit
- Conclusion
- Frequently Asked Questions
- Think You’ve Mastered Cherry-Picking? Take A Quiz!
Table of content:
- When To Use Git Tags?
- Creating A Git Tag
- Types Of Git Tags
- Listing Git Tags
- Tagging Old Commits
- ReTagging Or Replacing Old Git Tags
- Sharing: Pushing Git Tags To Remote
- Deleting Git Tags
- Checking Out Git Tags
- Git Tags: Manage & Add Versions To Project History
- Git Tags & History of Commits
- Conclusion
- Common Git Tags Questions/FAQs
- Git Tag Quiz – Ready to Test Yourself?
Table of content:
- What Are Git Hooks?
- How To Create GIT Hooks?
- Scripting Languages In Git Hooks
- Scope Of Git Hooks
- Types Of Git Hooks
- Difference Between Client-Side & Server-Side Hooks
- Local Git Hooks & Workflow
- Types Of Server-Side Hooks & Their Functions
- How To Use Different Git Hook Scripts?
- Application Of Git Hooks With Examples
- How To Find and Fix Trailing Whitespace In Commits?
- Tips For Writing Effective Git Hooks
- Conclusion
- Frequently Asked Questions
- Git Hooks Quiz – How Well Do You Know Them?
Git Submodule: Add, Remove, Pull Changes & More (With Examples)

Git is a widely-used version control system that allows developers to track and manage changes to their codebase. One feature that sets Git apart from other version control systems is its ability to handle submodules. Git submodules are a powerful tool that can help you manage dependencies and keep your source code organized. In this article, we will discuss what Git submodules are, how they work, and how you can use them effectively.
What Are Git Submodules?
Git submodules are a feature of Git that allows you to include one Git repository as a subdirectory within another Git repository. This can be useful if you want to use code files from another repository in your project without actually copying them into your repository.
When you add a Git submodule path to your repository, Git creates a special entry in your repository's config file that points to the submodule's URL and the location where it should be cloned. When you clone the main repository, Git will automatically clone the submodules as well, and initialize them as separate external repositories within your main repository's directory tree or project tree.
Submodules can be updated independently of the main repository, which means that you can keep the code in the submodule up-to-date with the upstream repository without having to manually copy and paste changes into your main repository. However, working with submodules can be complex, especially when it comes to managing changes and merging code between repositories.
How Git Submodules Work?
Git submodule is a way to include a Git repository as a subdirectory within another Git repository. It allows you to keep a separate repository for a specific component or library that you want to include in your project.
Here's how it works:
-
First, you need to add a submodule to your repository. This can be done using the command, followed by the URL of the repository you want to include and the path where you want it to be located within your project.
-
Git will create a new file called in the root directory of your repository. This file contains information about the submodule, including the URL, the path, and the commit SHA of the specific version of the submodule that is included.
-
When you commit and push changes to your main repository, the submodule will not be included in the commit. Instead, the commit will include a reference to the specific commit SHA of the submodule that is included.
-
To update the submodule to a new version, you can use the command. This will fetch the latest changes from the submodule repository and update the reference to the new commit SHA in your main repository.
-
To make changes to the committed submodule itself, you need to navigate to the submodule directory and work on it like any other Git repository. When you commit and push changes to the submodule repository, you will also need to update the reference to the new commit SHA in your main repository.
How To Add Git Submodule?
The command is used to add a submodule to your repository. The syntax for the command is as follows:
git submodule add <repository URL> <path>
Here, is the URL of the repository that you want to add as a submodule and is the path where you want the submodule to be located within your repository.
For example, if you wanted to add a submodule for the repository located at , and you wanted the submodule to be located in a directory called within your repository, you would run the following command:
git submodule add https://github.com/my-account/my-library.git lib
This would create a new directory called within your repository, and clone the repository into that directory as a submodule. Git would also create a new entry in your repository's file to track the submodule.
Once you have added a submodule to your repository, you can use the command to clone the submodule and initialize it within your repository.
How To Remove Git Submodule?
To remove a submodule in Git, follow these steps:
-
Navigate to the root directory of your Git repository in your terminal to check the version history of the current Git branch.
-
Use the following command to list all the submodules present in your repository contents:
git submodule
-
Identify the submodule you want to remove from the list of submodules.
-
Use the following command to remove the submodule:
git submodule deinit <path_to_submodule>
Replace with the relative path to the submodule, you want to remove. For example, if your submodule is located at , you would run:
git submodule deinit path/to/submodule
-
Use the following command to remove the submodule from the Git index:
git rm <path_to_submodule>
Again, replace with the relative path to the submodule, you want to remove.
-
Use the following command to remove any leftover Git references to the submodule:
rm -rf .git/modules/<path_to_submodule>
Replace with the same path used in step 4.
-
Commit your changes using the following command:
git commit -m "Removed submodule <path_to_submodule>"
-
Replace with the same path used in steps 4 and 6.
That's it! The submodule should now be completely removed from your Git repository.
Pulling In Upstream Changes From The Submodule Remote
When working with submodules in Git, it is common to have a submodule that tracks a remote repository. You can pull in changes from the submodule's remote repository to update your local repository.
To pull in upstream changes from the submodule remote, you need to perform the following steps:
- Change to the submodule directory:
- Fetch changes from the upstream remote:
- Checkout the branch you want to update:
- Merge the changes from the upstream remote into your local branch:
- Commit the changes:
- Push the changes to the submodule's remote:
After completing these steps, your local submodule repository will be updated with the changes from the upstream remote repository.
It's important to note that pulling in upstream changes from a submodule remote does not automatically update the parent repository. You'll need to commit the changes in the submodule and push them to the parent repository to update it.
Git Submodule Commands
Here are some of the most commonly used submodule commands:
-
: Git submodule init command initializes all the submodules in your repository. The Git submodule init command clones the submodule repositories into the directory and checks out the submodule commits.
-
: Updates all the original submodule repositories to their latest commits.
-
: The git status command is a commonly used command in Git that allows you to view the current state of your local repository.
-
: Initializes and updates all the submodules in your repository.
-
: The git checked-out submodule commit is a fundamental command in Git that allows you to switch between different default branches or commits in the parent module in Git repository.
-
: Updates all the submodules in your repository and their submodules (if any) recursively.
-
: Runs a Git command on each submodule. For example, will run on each submodule.
-
: Shows the status of each submodule in your repository, including the commit hash and whether the submodule is up-to-date.
-
: Synchronizes the URL of each submodule with the URL listed in the file.
-
: Removes the submodule at the specified path from your repository. This command does not delete the submodule repository itself.
-
: Updates each submodule to the latest commit on its remote master branch.
-
: The clone command is used to clone a single repository that contains one or more submodules. Submodules are separate Git code repositories that are embedded inside another Git repository.
Uses Of Git Submodules
Git submodules are used in large projects to incorporate external repositories as dependencies. This allows developers to reuse code across submodule projects, manage external dependencies, and keep the codebase and package management organized.
Here are some common use cases for Git submodules:
-
Incorporating third-party libraries: You can use submodules to include external libraries into your submodule project as dependencies. This makes it easier to manage updates and keep the codebase organized.
-
Sharing external code between projects: Submodules allow you to share the actual code across different projects. You can have a common submodule code that is shared across multiple projects with submodules and configuration files, and any changes made to the common codebase will be reflected in the project repository.
-
Managing complex projects: Git submodules are useful for managing complex projects with multiple repositories. By using submodules, you can manage the dependencies between different repositories and keep the codebase organized.
-
Versioning control: Submodules allow you to track the version of a specific repository at a specific point in time. This can be useful when you need to ensure that a specific version of a dependency is used.
Overall, Git submodules provide a way to manage external dependencies and share external code across projects while keeping the codebase organized and maintainable. However, it's important to understand how the concept of submodules works and how to properly manage them to avoid potential issues.
Mastered Git Submodules? Test Yourself!
You might also be interested in reading the following:
- What Is GitHub? An Introduction, How-To Use It, Components & More!
- Introduction To Git Stash | How To Use Git Stash Commands
- What Is Bash? Features, Major Concepts, Commands, & More!
- What Is Linux Shell? Definition, Features, Types & More!
- What Is C++? An Introduction To C++ Programming Like No Other!
An economics graduate with a passion for storytelling, I thrive on crafting content that blends creativity with technical insight. At Unstop, I create in-depth, SEO-driven content that simplifies complex tech topics and covers a wide array of subjects, all designed to inform, engage, and inspire our readers. My goal is to empower others to truly #BeUnstoppable through content that resonates. When I’m not writing, you’ll find me immersed in art, food, or lost in a good book—constantly drawing inspiration from the world around me.
Comments
Add commentLogin to continue reading
And access exclusive content, personalized recommendations, and career-boosting opportunities.
Juhi Pant 5 hours ago
Kashni Gulati 5 hours ago
Gopinath GM 7 hours ago
Ankita Kanakagiri 13 hours ago
Sidratul Zuha 14 hours ago
Preethi Lalitha Chalapati 22 hours ago