Is there any way to move submodules within your superproject without removing them first and re-adding them ?
It automatically pulls in the submodule data assuming you have already added the submodules to the parent project. Note that --recurse-submodules and --recursive are equivalent aliases.
Git Submodules Moving a submodule If needed, create the parent directory of the new location of the submodule ( mkdir -p new/path/to ). Move all content from the old to the new directory ( mv -vi old/path/to/module new/path/to/submodule ). Make sure Git tracks this directory ( git add new/path/to ).
Enter the master repository's . git/modules directory, and find the directory corresponding to your submodule. Edit the config file, updating the worktree path so that it points to the new location of the submodule's working directory.
In most cases, Git submodules are used when your project becomes more complex, and while your project depends on the main Git repository, you might want to keep their change history separate. Using the above as an example, the Room repository depends on the House repository, but they operate separately.
It's similar to how you removing a submodule (see How do I remove a submodule?):
git add .gitmodules
mkdir -p new/parent
mv -vi old/parent/submodule new/parent/submodule
git rm --cached old/parent/submodule
Looks like this for me afterwards:
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: .gitmodules
# renamed: old/parent/submodule -> new/parent/submodule
#
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