Introduction
Assist is an extremely modular software, composed of numerous plugins that are hosted on different repositories. A simple way to manage Assist plugins is by including these repositories as Git submodules. This document provides essential instructions for updating submodules in the Assist software repository to ensure all submodules and their dependencies are correctly initialized and updated.
Adding a Submodule
To add a submodule to your Git repository, follow these steps:
- Create a directory for the submodule: Open your terminal and navigate to the root directory of your Git repository. Then, create a directory where the submodule will reside. Replace PLUGIN with the desired directory name.
- Add the submodule: Use the git submodule add command followed by the URL of the external repository you want to include. Replace PATH_TO_REPO_GIT with the actual URL of the repository.
git submodule add PATH_TO_REPO_GIT PLUGIN
This command will add the submodule and create an entry in the .gitmodules file. The submodule will be cloned into the specified directory.
- Commit the changes: After adding the submodule, commit the changes to your repository.
git commit -m "Added submodule: [name_of_submodule]"
Updating Submodules for Assist
To ensure that all submodules within the Assist repository are up-to-date, follow these steps:
- Initialize the submodules: If this is the first time you are working with the submodules in your repository, initialize them using the git submodule init command. This command initializes the local configuration file for submodules, preparing them for use.
- Update the submodules: To fetch the latest changes from the submodule repositories and update the working tree, use the git submodule update command with the –recursive flag to ensure all nested submodules are also updated.
git submodule update --recursive
Handling Nested Submodules
Sometimes, submodules themselves contain other submodules. In such cases, use the following commands to initialize and update all submodules and their dependencies recursively:
- Initialize all submodules and their dependencies:
git submodule foreach --recursive git submodule init
- Update all submodules and their dependencies:
git submodule foreach --recursive git submodule update
Removing a submodule
To remove a submodule, you need to delete the relevant entry from the .gitmodules and .git/config files, remove the submodule's directory, and commit the changes.
git submodule deinit -f -- PATH_TO_SUBMODULE
rm -rf PATH_TO_SUBMODULE
git rm -f PATH_TO_SUBMODULE
git commit -m "Removed submodule: [name_of_submodule]"
Set a submodule to a specific branch
The git submodule set-branch command is used to set or update the branch of a submodule to track a specific branch. This is useful when you want a submodule to always track a particular branch of its repository, rather than a specific commit.
git submodule set-branch --branch BRANCH -- sofa/SofaSolvers