Update git submodule

This commit is contained in:
mustafa-rezae 2025-03-11 15:09:49 +03:30
parent 0f155d2f04
commit f00f10ca3d

View File

@ -15,11 +15,38 @@ Updating Submodules
To update a submodule to the latest commit on its branch:
git submodule update --remote
Removing a Submodule
Removing a submodule is a bit more involved:
## How to Remove an Existing Submodule
Remove the submodule entry from .gitmodules.
Stage the .gitmodules changes: git add .gitmodules.
Remove the submodule from the working tree and index: git rm --cached <path-to-submodule>.
Delete the submodule directory: rm -rf <path-to-submodule>.
Commit the changes: git commit -m "Removed submodule <submodule-name>".
If the path was previously added as a submodule, you need to remove it completely before re-adding it. Follow these steps:
1. Remove the submodule entry from .gitmodules.
2. Remove the submodule from the working tree and index: git rm --cached <path-to-submodule>.
3. Delete the submodule directory: rm -rf <path-to-submodule>.
4. Stage the .gitmodules changes: git add .gitmodules.
5. Commit the changes: git commit -m "Removed submodule <submodule-name>".
errors:
# repo already exists and is not a valid git repo
Check if the path is already tracked
git ls-files --stage systems/chat_ui (100644 <hash> 0 <path>)
If it is, remove it from the index
git rm --cached systems/chat_ui
If system/chat_ui exits, remote it(chat_ui)
rm -rf systems/chat_ui
Add the submodule
git submodule add https://github.com/example/repo.git systems/chat_ui
Commit the changes
git commit -m "Added submodule at systems/chat_ui"
Verify the submodule
git submodule status
(Optional) Initialize and Update the Submodule
If the submodule was added successfully but not initialized, run:
git submodule update --init --recursive