# 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 👇

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1698055150808/c9982c26-4e02-49ec-bcf1-3f33b1ea31a3.gif align="left")

### 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

1. Local Repository
    
2. Branches
    
3. Commits
    
4. Module
    
5. Stash
    

### On this Post

In this post, we are going to see the topic **Module** which has the following sub-topics like

1. Add a submodule
    
2. Pull all submodules from remote
    
3. Clone missing submodules
    
4. Delete a submodule
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1698055152767/d67b1627-3af4-4ce1-97c9-cf365c2dd328.png align="left")

### 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](https://github.com/nidhinkumar06/HTML-LayoutPatterns) ./patterns  
*\# Creates the directory \`patterns\` containing the submodule from*  
*\# "*[https://github.com/nidhinkumar06/HTML-LayoutPatterns](https://github.com/nidhinkumar06/HTML-LayoutPatterns)*"*

### 2\. Pull all submodules from remote

Pulls all submodules from their respective remotes.

* Use `git submodule update --recursive --remote` to 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 --recursive` to 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!

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1698055154599/fa0ef08a-49bf-4399-9fa7-f3cdf07340bc.gif align="left")
