020.10 b
Description: Let's cover a submodule that's useful when you have multiple projects. Useful when you have B, C, D independent projects inside a big A project. However, it increases complexity.
#000#IT_Knowledge#020#Operation_Knowledge#020.10#Git#020.10 b#git_commands
How can I easily manage multiple git projects?
Audience
Users who want to manage multiple sub-projects within a single main project.
Features
Sub-projects are managed as files within submodules, using the 'git submodule' command.
Subprojects and the main project will each have their own git project, and will be managed separately from the main project
Submodules are manged by .gitmodules file
Usage
Here's a situation where you have a main project and a subproject, and you want to connect the two projects through a submodule
Add submodule-specific information to a main project that doesn't have any submodules
git submodule add <git-submodule-url> <main-project-path>
Set submodule-specific information locally with this commands
git submodule init
get directory sub module
git submoudle update
Update git submodule files
** Submodules are managed independently from the main project. So you have to do update manualy **
git submodule update --remote
Trouble Shooting when `fatal: Unable to find refs/remotes/origin/HEAD revision in submodule path 'some_dir/some_child'
When I update remote submodule, i got error fatal can't find HAED.
fatal: Unable to find refs/remotes/origin/HEAD revision in submodule path 'Manage/Librarian'
The solution is execute this CLI command in local submodule.
git remote set-head origin -a
I search why this happened.
Because usually I thought when I execute git submodule update --remote
, automatically local submodule update from the version that the latest from remote project.
In conclusion, there is default process that for keeping your local submodule, automatically detached from remote branch HEAD.
There are two things why I though like that
- I solved first error by command that about reset head
- After I succeed submodule update remote, current branch changes commit id not main branch
It is reasonable . But in my case, I'm the only one who managed this submoudle project. So it doesn't, need I change the default setting.
Thus setting can change by add setting to