它类似于你如何去除一个小单元(见)。 我如何去除一个小单元?:
- Edit .gitmodules and change the path of the submodule appropriately, and put it in the index with
git add .gitmodules
- If needed, create the parent directory of the new location of the submodule:
mkdir -p new/parent
- Move all content from the old to the new directory:
mv -vi old/parent/submodule new/parent/submodule
- Remove the old directory with
git rm --cached old/parent/submodule
之后,我想到:
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: .gitmodules
# renamed: old/parent/submodule -> new/parent/submodule
#
- Finally commit the changes.