https://stackoverflow.com/questions/11358082/empty-git-submodule-folder-when-repo-cloned
.gitmodules
[submodule "external/common"]
path = external/common
url = ../common.git
[submodule "external/project"]
path = external/project
url = ../project.git
[submodule "external/tools"]
path = external/tools
url = ../tools.git
git submodule update --init
How to git add submodule with error "already exists in the index"?
https://stackoverflow.com/questions/12898278/issue-with-adding-common-code-as-git-submodule-already-exists-in-the-index
You need to remove your submodule git repository (projectfolder in this case) first for git path.
rm -rf projectfolder
git rm -r projectfolder
git submodule add <ssh/https> projectfolder
git submodule add git@gitlab.com:user/project.git external/project
Git submodule with branch
https://stackoverflow.com/questions/1777854/how-can-i-specify-a-branch-tag-when-adding-a-git-submodule
Existing answers have the second step missing and overloaded with details.
To switch an existing submodule to track a new remote url and/or a new branch:
- Edit the source of truth in
.gitmodules
.
For example, from
[submodule "api"]
path = api
url = https://github.com/<original_repo>/api.git
to
[submodule "api"]
path = api
url = https://github.com/<another_repo>/api.git
branch = work-in-progress
git submodule sync
: Updates the description of submodules cached by git in.git/modules
from the just-edited source of truth specified in.gitmodules
.git submodule update --init --recursive --remote
: Updates the checked-out submodules in the working copy.Commit the changes.
沒有留言:
張貼留言