DevOps Roadmap — Part 6: Git & Version Control

Agar DevOps ka backbone kuch hai, toh woh Git hai.

Automation scripts, Docker files, CI/CD pipelines — sab Git ke bina meaningless hain.


What Is Version Control?

Version control ka matlab:

Git bina DevOps possible nahi hai.


Why DevOps Engineers Need Git

Production systems me “undo” sirf Git deta hai.


Install Git

Ubuntu / Debian
sudo apt update
sudo apt install git -y
Check version
git --version

Basic Git Configuration

Set name & email
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"

Ye identity commits ke sath store hoti hai.


Create Your First Repository

Initialize repo
mkdir devops-project
cd devops-project
git init

Ab ye folder Git controlled ho gaya.


First Commit

Create file
echo "DevOps Learning" > readme.txt
Check status
git status
Add & commit
git add .
git commit -m "Initial commit"

Commit = snapshot of your project.


Understanding Git Workflow

DevOps automation always follows this flow.


Branches — Safe Experimenting

Create branch
git branch dev
Switch branch
git checkout dev

Production directly edit karna suicide hai. Branches safety dete hain.


Merge Branches

Merge dev into main
git checkout main
git merge dev

CI/CD pipelines yahin se start hoti hain.


GitHub — Remote Repositories

Git local hota hai, GitHub cloud me hota hai.

Add remote
git remote add origin https://github.com/username/repo.git
Push code
git push -u origin main

Common DevOps Mistakes

Git discipline = DevOps discipline.


What Comes Next?

Ab jab code versioned hai, next step hai Containers.

Next Part → Docker & Containers
Disclaimer:
Never commit passwords, API keys, or secrets into Git repositories.