Collaborating on GitHub: A DevOps Engineer’s Guide

Table of contents
- What is a GitHub Repository?
- Why Do We Need a GitHub Repository?
- Why is GitHub So Popular?
- Creating a GitHub Account & Logging In
- Creating a New Repository on GitHub
- Cloning the Repository in VS Code
- Creating & Editing Files in VS Code
- Adding, Committing, and Pushing Changes
- Pulling Changes from GitHub
- Working with Branches
- Pull Requests (PRs) for Code Reviews
- Merging the PR and Deleting the Branch
- Team Workflows: Forking vs. Branching
- DevOps Best Practices on GitHub
- Conclusion

Hello, my fellow DevOps Engineers! Today, we’re diving into a crucial topic—GitHub! Whether you’re a Developer or a DevOps Engineer, GitHub is where all the magic happens—code storage, collaboration, version control, and reviews. Mastering GitHub is essential for efficient teamwork, CI/CD pipelines, and seamless deployments.
So, without further ado, let’s jump right in!
What is a GitHub Repository?
A GitHub repository (repo) is a storage space for your code, files, and version history. It allows multiple developers to work together using Git.
🔹 Local Repository – Exists on your computer.
🔹 Remote Repository – Exists on GitHub, accessible from anywhere.
💡 A GitHub repo is like a cloud-based Git project that enables easy sharing, collaboration, and version control.
Why Do We Need a GitHub Repository?
A GitHub repo helps with:
Version control – Track changes over time.
Collaboration – Multiple developers can work together.
CI/CD Integration – Automate testing & deployments.
Backup & Security – Store code safely in the cloud.
Open Source Contributions – Share your projects with the world.
Why is GitHub So Popular?
Free and easy to use
Supports private & public repositories
Seamless integration with DevOps tools (Jenkins, Docker, Terraform, etc.)
Pull Request (PR) workflows for better collaboration
GitHub Actions for CI/CD automation
Creating a GitHub Account & Logging In
Step 1: Open GitHub in Your Browser
Go to 👉 GitHub
Step 2: Sign Up for an Account
1️⃣ Click "Sign up"
2️⃣ Enter Username, Email, and Password
3️⃣ Click "Create account"
4️⃣ Verify your email and set up your profile.
Step 3: Log In
Once signed up, log in anytime by entering your email and password.
Creating a New Repository on GitHub
Step 1: Create a Repository
Click + → New repository.
Name your repo (e.g.,
devops_git_demo
).Add a description: "Repository for DevOps GitHub series of DevOpsVoyage blog".
Select Public (or Private).
Check Add a README file → Create repository.
Cloning the Repository in VS Code
Step 1: Copy the Repository URL
- On your GitHub repo page, click Code → Copy the HTTPS URL (e.g.,
https://github.com/RajGaik26/devops_git_demo.git
).
Step 2: Clone in VS Code
1️⃣ Open VS Code and open the terminal.
2️⃣ Clone the repo into VS Code:
git clone https://github.com/RajGaik26/devops_git_demo.git
3️⃣ Move into the repo directory:
cd devops_git_demo/
Creating & Editing Files in VS Code
Step 1: Create a New File (Python Example)
1️⃣ Right Click on "Explorer" (Ctrl + Shift + E)
2️⃣ Click "New File", name anything you wish:
print("Hello, DevOps Engineers!")
3️⃣ Save the file (Ctrl + S)
Adding, Committing, and Pushing Changes
Step 1: Check File Status
git status
You will see hello.py
as untracked (red text).
Step 2: Add the File to Staging
git add hello.py
The file is now staged (green text).
Step 3: Commit the Changes
git commit -m "Add hello.py file"
Your changes are now saved locally but have not yet been uploaded to GitHub.
Step 4: Push the Code to GitHub
git push origin main
🎉 Your code is now on GitHub!
Pulling Changes from GitHub
If your teammate adds a new file on GitHub, you should pull updates before making further changes.
git pull origin main
This fetches and merges the latest updates.
Working with Branches
Step 1: Create a New Branch
git checkout -b feature-branch
You are now on a new branch called feature-branch
.
Step 2: Add a New File (Calculator Example)
1️⃣ Create a new file calculator.py and add:
def add(a, b):
return a + b
def subtract(a, b):
return a - b
def multiply(a, b):
return a * b
def divide(a, b):
if b == 0:
return "Cannot divide by zero!"
return a / b
print("Simple Calculator")
print("-----------------")
while True:
print("\nSelect operation:")
print("1. Add")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")
print("5. Exit")
choice = input("Enter choice (1/2/3/4/5): ")
if choice == '5':
print("Calculator exited.")
break
if choice not in ['1', '2', '3', '4']:
print("Invalid input! Please try again.")
continue
try:
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
except ValueError:
print("Invalid input! Please enter numbers only.")
continue
result = None
if choice == '1':
result = add(num1, num2)
elif choice == '2':
result = subtract(num1, num2)
elif choice == '3':
result = multiply(num1, num2)
elif choice == '4':
result = divide(num1, num2)
print(f"\nResult: {result}")
2️⃣ Save the file (Ctrl + S)
Step 3: Add, Commit, and Push the Branch
git add calculator.py
git commit -m "Add Calculator file"
git push origin feature-branch
🎉 Your code is now on GitHub!
Pull Requests (PRs) for Code Reviews
DevOps Workflow Example
Scenario: A teammate adds a security patch to your Terraform config.
Create a Feature Branch:
- In VS Code’s bottom panel, click the branch name (e.g.,
main
) → Create new branch →feature/security-patch
.
- In VS Code’s bottom panel, click the branch name (e.g.,
Make Changes:
Update
main.tf
to use a newer AMI (Example):ami = "ami-0ff8a91507f77f867"
Commit & Push the Branch:
- Stage changes → Commit → Push (VS Code will prompt to publish the branch).
Open a Pull Request:
Go to your GitHub repo → Pull Requests → New Pull Request.
Set
base: main
andcompare: feature/security-patch
.Add a reviewer and click Create PR.
Merge After Approval:
- Once reviewed, click Merge pull request → Confirm merge.
Merging the PR and Deleting the Branch
Once the PR is approved:
git checkout main
git pull origin main # Ensure the latest changes are fetched
git merge feature/security-patch
git push origin main
After merging, delete the branch:
git branch -d feature/security-patch
git push origin --delete feature/security-patch
Team Workflows: Forking vs. Branching
Forking Strategy
Fork the Repository:
- Click Fork on the repo page to create your copy (e.g., for open-source contributions).
Clone & Push:
- Work on your fork → Submit PRs to the original repo.
Branching Strategy
Feature Branches:
- Prefix branches with
feature/
,bugfix/
, orhotfix/
(e.g.,feature/ansible-role
).
- Prefix branches with
Protected Branches:
- In GitHub repo settings → Branches → Add rule for
main
to require PR approvals.
- In GitHub repo settings → Branches → Add rule for
DevOps Best Practices on GitHub
GitHub Actions for CI/CD:
- Add a
.github/workflows/deploy.yml
file to automate Terraform deployments.
- Add a
Secrets Management:
- Store API keys/AWS credentials in Settings → Secrets → Actions.
Code Scanning:
- Enable Dependabot to detect vulnerabilities in dependencies.
Conclusion
✔ Cloning, branching, and committing is now easy inside VS Code!
✔ Push and pull operations ensure you always have the latest code.
✔ PRs help you collaborate effectively in DevOps workflows.
✔ Forking lets you contribute to external projects.
Finally, we’re done! Give yourselves a round of applause—you’ve earned it! What an incredible ride this has been. Let’s take a moment to reflect on everything we’ve covered in this Git and GitHub series:
✅ Introduction to Git: Version Control for DevOps Engineers
✅ Installing Git and Writing Your First Command: A Beginner’s Guide
✅ Git Branching and Merging: A Practical Guide for DevOps
✅ Advanced Git Workflows for DevOps: Stash, Rebase, Diff, and Cherry-Pick
✅ Collaborating on GitHub: A DevOps Engineer’s Guide
These topics have set you on the path to mastering Git and GitHub, but remember—learning doesn’t stop here! The key to truly becoming a pro is consistent practice. Keep using Git in your projects, experiment with different workflows, and push yourself to explore more advanced features.
And guess what? We’re just getting started! While this series may be ending, the learning never stops! A new journey begins as we dive into our next series: "Networking"
As they say, New day, new topic! And trust me, you don’t want to miss this one. Stay tuned.
Until next time, keep coding, automating, and advancing in DevOps! 😁
Peace out ✌️
Subscribe to my newsletter
Read articles from Rajratan Gaikwad directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Rajratan Gaikwad
Rajratan Gaikwad
I write about the art and adventure of DevOps, making complex topics in CI/CD, Cloud Automation, Infrastructure as Code, and Monitoring approachable and fun. Join me on my DevOps Voyage, where each post unpacks real-world challenges, explores best practices, and dives deep into the world of modern DevOps—one journey at a time!