User Tools

Site Tools


git:git-submodules

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
git:git-submodules [2023/05/02 16:30] – created admingit:git-submodules [2023/05/07 19:26] (current) admin
Line 9: Line 9:
 Where **git URL** is the URL of the git repo and path is where this git repo is stored in the main git. Where **git URL** is the URL of the git repo and path is where this git repo is stored in the main git.
  
-For example we are working in the git repo **submodules_main** and we would like to use an external git (URL=https://gitlab.com/bnzr/python_control_coppeliasim.git)+For example we are working in the git repo **submodules_main** and we would like to use an external git at URL https://gitlab.com/bnzr/python_control_coppeliasim.git
 <code bash> <code bash>
 mkdir external mkdir external
 +git clone https://gitlab.com/bnzr/python_control_coppeliasim.git 
 git submodule add https://gitlab.com/bnzr/python_control_coppeliasim.git external/python_control_coppeliasim/ git submodule add https://gitlab.com/bnzr/python_control_coppeliasim.git external/python_control_coppeliasim/
 </code>   </code>  
  
 +We can list the submodules with :
 +<code bash>
 +git submodule foreach --quiet 'echo $name'
 +</code>  
 +
 +Information on submodules can be found in  **.gitmodules** and **.git/config** of the main project git
 +
 +If we add the changes, commit and push , the content of submodules will not been added in the main project git, but information on how to retrieve it will be stored. In our example we push the changes :
 +<code bash>
 +git add --all
 +git commit -m "add python_control_coppeliasim external git repo"
 +git push
 +</code>
 +
 +In another computer we can simply clone the main project repo and we will see that there is nothing in the submodule. The content of the submodules can be pulled by 
 +<code bash>
 +git clone <git URL> 
 +cd <git repo main folder>
 +git submodule update --init
 +</code>
 +If we know when cloning the main project git that there are submodules we can pull them at the start with **--recursive** keyword:
 +<code bash>
 +git clone <git URL> --recursive
 +</code>
git/git-submodules.1683037846.txt.gz · Last modified: 2023/05/02 16:30 by admin