Let's say my repo index root is in /project
dir.
Should the .gitmodules
also be inside this dir, or can I put it into, say /project/subdir
?
The reason I would like to do that is because I have multiple contributors and I want each to be responsible for his own set of submodules.
In order to add a Git submodule, use the “git submodule add” command and specify the URL of the Git remote repository to be included as a submodule. When adding a Git submodule, your submodule will be staged. As a consequence, you will need to commit your submodule by using the “git commit” command.
The . gitmodules file, located in the top-level directory of a Git working tree, is a text file with a syntax matching the requirements of git-config[1]. The file contains one subsection per submodule, and the subsection value is the name of the submodule.
Cloning a Project with Submodules If you pass --recurse-submodules to the git clone command, it will automatically initialize and update each submodule in the repository, including nested submodules if any of the submodules in the repository have submodules themselves.
A submodule can be located anywhere in a parent Git repository's working directory and is configured via a . gitmodules file located at the root of the parent repository. This file contains which paths are submodules and what URL should be used when cloning and fetching for that submodule.
man gitsubmodule
on Debian Wheezy says:
...
SYNOPSIS
$GIT_WORK_DIR/.gitmodules
...
According this default place for .gitmodules file is a top-level directory of the git working tree. So, lets say you have such project structure:
project/
|
|--subproject-1/
| `--.gitmodules
|--subproject-2/
| `--.gitmodules
|--.gitmodules
.gitmodules in your project root dir will define modules subproject-1 and subproject-2. Subprojects dependent modules also can be defined with subproject-N/.gitmodules, but those settings will affect only in proper subproject scope.
To update your project dependencies you should use command:
git submodule update
But if you want to update also dependencies of subproject-1 and subproject-2 use:
git submoudle update --recursive
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With