Submodules
A Git submodule is a repository embedded within another repository. It allows you to include and manage external repositories as part of your project. Submodules are useful for including libraries, dependencies, or other projects that you want to keep separate from your main repository.
Adding a Submodule
To add a submodule to your Git repository, you can use the following command:
git submodule add <repository_url> <path>
switching to submodule
To switch to a submodule, you can use the following command:
git submodule update --init --recursive
Removing a Submodule
To remove a submodule from your repository, you can use the following command:
git submodule deinit <path>
git rm -rf <path>
Updating a Submodule
To update a submodule, you can use the following command:
git submodule update --recursive
git submodule update <path>
pushing a submodule
To push a submodule, you can use the following command:
git submodule add <repository_url> <path>
git commit -m "Add submodule"
git push
submodule status
To check the status of a submodule, you can use the following command:
git submodule status
submodule log
To view the commit history of a submodule, you can use the following command:
git submodule log
submodule diff
To view the changes made to a submodule, you can use the following command:
git submodule diff
submodule branch
To view the branches of a submodule, you can use the following command:
git submodule branch
git submodule branch <branch_name>
submodule checkout
To checkout a specific branch of a submodule, you can use the following command:
git submodule checkout <branch_name>
submodule merge
To merge changes from a submodule into the main repository, you can use the following command:
git submodule merge <submodule_branch>
submodule update
To update a submodule, you can use the following command:
git fetch <submodule_url>
git reset --hard <submodule_version>
submodule push
To push changes to a submodule, you can use the following command:
git push <submodule_url> <submodule_branch>
submodule clone
To clone a submodule to a separate path:
git submodule clone <submodule_url> <submodule_path>