How to change git tracking submodules of a remote branch?

I add a submodule using the following command

git subodule add -b br1 [repo]

The .gitmodules file has an input branch = br1. Now I want to switch the branch to br2. I can go into the submodule folder and switch the branch, but this does not update the .gitmodules file.

How can i do this?

+4
source share
1 answer

Git uses .gitmodules to store a link to your submodule project, but not a specific version. Therefore, when you switch the submodule branch, the git.gitmodules file does not change.

Instead, git updates the number of updates to your submodule when the submodule changes. If you look at your top module

git diff

you will see something like

-Subproject commit 829b869657418fdac7964c3671ed9a378f09c032
+Subproject commit 829b869657418fdac7964c3671ed9a378f09c032-dirty

, , ( ) .

.

: https://git-scm.com/book/en/v2/Git-Tools-Submodules#Starting-with-Submodules

+1

Source: https://habr.com/ru/post/1606225/


All Articles