Updating a submodule and then reflecting those updates in the parent repository.
-
Navigate to the Submodule Directory
- Change into the submodule's directory from the root of the parent repository.
cd path/to/submodule
- Change into the submodule's directory from the root of the parent repository.
-
Check Out the Desired Branch
- Ensure you're on the branch you want to update.
git checkout main # Or another branch you're updating
- Ensure you're on the branch you want to update.
-
Pull the Latest Changes
- Fetch and merge the latest changes for the branch from the remote.
git pull origin main
- Fetch and merge the latest changes for the branch from the remote.
-
Stage the Submodule Changes
- Add the submodule changes to be tracked by the parent repository. This action updates the parent to point to the latest commit of the submodule.
git add .
- Add the submodule changes to be tracked by the parent repository. This action updates the parent to point to the latest commit of the submodule.
-
Commit the Submodule Changes
- Commit the update in the parent repository to record the change in the submodule reference.
git commit -m "Update submodule to latest commit" git push
- Commit the update in the parent repository to record the change in the submodule reference.
- Push the Changes to the Parent Repository
- Push the updates from the parent repository to the remote. This ensures that the parent repository correctly references the updated state of the submodule.
cd .. git checkout update-submodule-branch git add . git commit -m "message" git push
- Push the updates from the parent repository to the remote. This ensures that the parent repository correctly references the updated state of the submodule.
- Create pull request and merge changes
- Visit GitHub website, create the pull request and merge the changes.