Clone a git repository and add a submodule

Let\'s suppose you want to use the latest version of Python's requests module inside your project.

You want the module to be able to merge when upstream changes become available. Yet your customization on the module should be able to persist.

In this case, you need to add the external repository as a submodule with the git submodule add command like so :

nl@ubuntu:~/youtube-dl$ git submodule add https://github.com/psf/requests.git
Cloning into '/home/nl/youtube-dl/requests'...
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 24483 (delta 4), reused 6 (delta 2), pack-reused 24469
Receiving objects: 100% (24483/24483), 12.25 MiB | 258.00 KiB/s, done.
Resolving deltas: 100% (16065/16065), done.

After adding a submodule, you can go into the corresponding subdirectory and make your own changes, add our own writable remote repository to push your changes into. You will even be able to fetch and merge from the original repository maintained by the community.

Click to rate this post!
[Total: 0 Average: 0]

1 thought on “Clone a git repository and add a submodule”

Leave a Comment