Add submodule snippets
This commit is contained in:
18
snippets/add-submodule.md
Normal file
18
snippets/add-submodule.md
Normal file
@ -0,0 +1,18 @@
|
||||
---
|
||||
title: Add a submodule
|
||||
tags: repository,submodule,advanced
|
||||
---
|
||||
|
||||
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>`.
|
||||
|
||||
```sh
|
||||
git submodule add <upstream-path> <local-path>
|
||||
```
|
||||
|
||||
```sh
|
||||
git submodule add https://github.com/30-seconds/30-seconds-of-code ./30code
|
||||
# Creates the directory `30code` containing the submodule from
|
||||
# "https://github.com/30-seconds/30-seconds-of-code"
|
||||
```
|
||||
17
snippets/clone-missing-submodules.md
Normal file
17
snippets/clone-missing-submodules.md
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
title: Clone missing submodules
|
||||
tags: repository,submodule,advanced
|
||||
---
|
||||
|
||||
Clones missing submodules and checks out commits.
|
||||
|
||||
- Use `git submodule update --init --recursive` to clone missing submodules and checkout commits.
|
||||
|
||||
```sh
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
```sh
|
||||
git submodule update --init --recursive
|
||||
# Clones missing submodules and checks out commits
|
||||
```
|
||||
23
snippets/delete-submodule.md
Normal file
23
snippets/delete-submodule.md
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
title: Delete a submodule
|
||||
tags: repository,submodule,advanced
|
||||
---
|
||||
|
||||
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.
|
||||
|
||||
```sh
|
||||
git submodule deinit -f -- <submodule>
|
||||
rm -rf .git/modules/<submodule>
|
||||
git rm -f <submodule>
|
||||
```
|
||||
|
||||
```sh
|
||||
git submodule deinit -f -- 30code
|
||||
rm -rf .git/modules/30code
|
||||
git rm -f 30code
|
||||
# Removes the `30code` submodule
|
||||
```
|
||||
17
snippets/pull-all-submodules.md
Normal file
17
snippets/pull-all-submodules.md
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
title: Pull all submodules from remote
|
||||
tags: repository,submodule,advanced
|
||||
---
|
||||
|
||||
Pulls all submodules from their respective remotes.
|
||||
|
||||
- Use `git submodule update --recursive --remote` to pull all submodules from their respective remotes.
|
||||
|
||||
```sh
|
||||
git submodule update --recursive --remote
|
||||
```
|
||||
|
||||
```sh
|
||||
git submodule update --recursive --remote
|
||||
# Pulls all submodules from their respective remotes
|
||||
```
|
||||
Reference in New Issue
Block a user