Git for Noob-to-Pro — #4(Module)

If you don’t have time to read but want to know what’s there in this series. Find the quick read 👇

On this Series
We are going to see the commonly used Git snippets for the repository which will make you from Noob to Pro.
The Git Repository snippets that we are going to look at in this series are
Local Repository
Branches
Commits
Module
Stash
On this Post
In this post, we are going to see the topic Module which has the following sub-topics like
Add a submodule
Pull all submodules from remote
Clone missing submodules
Delete a submodule

1. Add a submodule
Adds a new submodule to the repository.
- Use
git submodule add <upstream-path> <local-path>to add a new submodule from<upstream-path>to<local-path>.
git submodule add
# Example
git submodule add https://github.com/nidhinkumar06/HTML-LayoutPatterns ./patterns
# Creates the directory `patterns` containing the submodule from
# "https://github.com/nidhinkumar06/HTML-LayoutPatterns"
2. Pull all submodules from remote
Pulls all submodules from their respective remotes.
- Use
git submodule update --recursive --remoteto pull all submodules from their respective remotes.
git submodule update --recursive --remote
**# Example
**git submodule update --recursive --remote
# Pulls all submodules from their respective remotes
3. Clone missing submodules
Clones missing submodules and checks out commit.
- Use
git submodule update --init --recursiveto clone missing submodules and checkout commits.
git submodule update --init --recursive
# Example
git submodule update --init --recursive
# Clones missing submodules and checks out commits
4. Delete a submodule
Deletes a submodule from the repository.
Use
git submodule deinit -f -- <submodule>to unregister the specified<submodule>.Use
rm -rf .git/modules/<submodule>to remove the directory of the submodule.Use
git rm -f <submodule>to remove the working tree of the submodule.
git submodule deinit -f --
rm -rf .git/modules/
git rm -f
**# Example
**git submodule deinit -f -- patterns
rm -rf .git/modules/patterns
git rm -f patterns
# Removes the `patterns` submodule
Congratulations!





