This document outlines the steps to initialize a Git repository, link it to a remote GitHub repository, and push changes.
If you haven't already, initialize a new Git repository in your project directory:
git init
Link your local Git repository to the remote GitHub repository. Replace https://github.com/repo with your actual GitHub repository URL:
git remote add origin <https://github.com/repo>
To verify that the remote repository has been added successfully, use the following command:
git remote -v
Stage all modified or newly added files in your repository:
git add .
Commit your staged changes with a meaningful message. For example:
git commit -m "Save all the files"
Finally, push your changes to the main branch on GitHub:
git push origin main
Example:
# Clone your repository
git clone https://github.com/Hatimloha/Terraform-Learn.git
cd Terraform-Learn
# Add the remote for the other repository
git remote add terraform-zero-to-hero https://github.com/iam-veeramalla/terraform-zero-to-hero.git
# Fetch the contents
git fetch terraform-zero-to-hero
# Merge the content from the other repo's main branch
git merge terraform-zero-to-hero/main
# Push the changes
git push origin main