Git: Add submodule to a Git repo

In my main git repo, I need to use the same code I developped before for another project. Fortunately, I put this code in a separate repo to be reusable.

In example, I want my submodule to be in a libs/ directory (I guess libs/ directory already exists).

$ git submodule add GIT_REPO_URL libs/REPO_NAME

And the result of git status:

$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: .gitmodules
# new file: REPO_NAME
#

 

That’s all folks!

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *