This guide will help you manage the Git submodule located at src/datadog
in the DataDog-Variables repository.
- Adding the Submodule
- Updating the Submodule
- Pushing Changes to the Submodule
- Pulling Changes from the Submodule
To add the DataDog Variables repository as a submodule in your own repository, follow these steps:
-
Navigate to Your Main Repository
Open your terminal and navigate to the directory of the main repository where you want to add the submodule.
cd /path/to/your/main/repo
-
Add the Submodule
Use the following command to add the submodule. Replace
<submodule-path>
with the desired path where the submodule will reside (e.g.,src/datadog
):git submodule add https://github.com/DepoIQ/DataDog-Variables.git <submodule-path>
Example:
git submodule add https://github.com/DepoIQ/DataDog-Variables.git src/datadog
-
Initialize and Update the Submodule
After adding the submodule, run the following command to initialize and fetch the submodule content:
git submodule update --init --recursive
-
Commit the Changes
After adding the submodule, commit this change to your main repository:
git add .gitmodules <submodule-path> git commit -m "Added DataDog-Variables as a submodule"
Example:
git add .gitmodules src/datadog git commit -m "Added DataDog-Variables as a submodule"
-
Push the Changes to Remote
Finally, push the changes to the remote repository:
git push origin main
To update the submodule to the latest commit in its remote repository, follow these steps:
-
Navigate to the submodule directory:
cd <submodule-path>
-
Pull the latest changes:
git pull origin main
-
Navigate back to the main project directory:
cd <main-project-path>
-
Commit the updated state of the submodule:
git add <submodule-path> git commit -m "Updated DataDog-Variables submodule" git push
If you make changes to the files in the submodule, you can push those changes back to the remote repository:
-
Navigate to the submodule directory:
cd src/datadog
-
Stage and commit your changes:
git add . git commit -m "Your commit message"
-
Push the changes to the remote repository:
git push origin master # or the relevant branch name
-
Navigate back to the main project directory:
cd ../../
-
Commit the updated submodule reference:
git add src/datadog git commit -m "Update submodule reference to latest commit" git push
To pull changes made to the submodule from its remote repository:
-
Navigate to the submodule directory:
cd src/datadog
-
Pull the latest changes:
git pull origin master # or the relevant branch name
-
Navigate back to your main project directory:
cd ../../
-
Commit the updated submodule reference:
git add src/datadog git commit -m "Update submodule reference after pulling changes" git push