Mastering Git — The Essential DevOps Skill

👩💻 Aspiring DevOps & Cloud Engineer | Learning in Public | Automation Enthusiast Hi! I’m Vaishnavi Landge, documenting my journey into DevOps, Cloud, CI/CD, and automation. I believe in learning by doing — this blog is my daily space to simplify concepts, share projects, and grow step by step. 🚀 Let’s build, automate, and deploy — together!
Git is a version control system — you can think of it as a time machine for your code.
It saves every change you make, lets many people work on the same project without clashing, and allows you to go back to older versions if something breaks.
Why is Git so popular?
It’s fast, lightweight, and essential for DevOps.
Why DevOps Engineers Must Know Git
In DevOps, we work together and automate everything.
Git makes this possible by:
📜 Tracking history — every change is recorded
🤝 Helping teamwork — multiple developers can work at the same time
🚀 Enabling automation — used in CI/CD pipelines
🔄 Allowing rollbacks — quickly fix mistakes
🌍 Working anywhere — on local machines or cloud platforms
Git vs GitHub (or GitLab, Bitbucket)
Git → The tool installed on your computer to track changes.
GitHub/GitLab/Bitbucket → Online platforms to store and share Git repositories.
Think of Git as the engine, and GitHub as the garage where you keep your car.
Installing Git (Linux Example)
sudo apt install git
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Basic Git Workflow
Git usually follows these steps:
Edit files
Stage changes →
git addSave changes →
git commitSend to remote →
git pushMerge changes if needed
Example:
# Start a new repo
git init
# Stage changes
git add filename
# Commit changes
git commit -m "Added new feature"
# Push to GitHub
git push origin main
Important Git Terms
| Term | Meaning |
| Repository (Repo) | A project with history of changes |
| Commit | A saved version of code |
| Branch | A separate copy for working on new changes |
| Merge | Combine changes from different branches |
| Clone | Copy a repo to your system |
| Pull | Get changes from remote |
| Push | Send your changes to remote |
| Staging Area | Place where changes wait before being committed |
Working with Branches
Branches help you work on new features without touching the main code.
# Check current branch
git branch
# Create a new branch
git branch new-branch
# Switch to that branch
git checkout new-branch
# Create and switch in one step
git checkout -b new-branch
# Merge branch into main
git checkout main
git merge new-branch
# Delete a branch
git branch -d new-branch
Merge Conflicts
A conflict happens when two people edit the same part of a file.
Git will mark it like this:
<<<<<<< HEAD
your changes
=======
their changes
>>>>>>> branch-name
To fix:
Open the file
Keep the correct changes
Remove the markers
Stage and commit again
Useful Git Commands for DevOps
| Command | Purpose |
git status | Show current state |
git log --oneline | Show commit history |
git diff | Show changes |
git stash | Save changes temporarily |
git reset --hard commit_id | Go back to a specific commit |
git tag | Mark a version |
git fetch | Get changes without merging |
git rebase | Move commits to another branch |
.gitignore — Hiding Unwanted Files
Example .gitignore file:
.env
node_modules/
*.log
It keeps secret or unwanted files out of Git.
Git in DevOps Pipelines
In CI/CD:
Developer pushes code to GitHub
CI/CD tool (Jenkins, GitHub Actions, etc.) detects the change
Code is built, tested, and deployed automatically
Common Git Mistakes (and Fixes)
❌ Pushing secrets → Use
.gitignore❌ Forgetting to pull → Run
git pull origin mainbefore push❌ Working directly on main → Use feature branches
❌ Overwriting history → Avoid
git push --forceunless needed
Best Practices for Teams
✅ Write clear commit messages
✅ Use branches for features
✅ Review code before merging
✅ Keep commits small
✅ Tag versions for releases
Interview Tip
Q: What’s the difference between git merge and git rebase?
merge → Keeps history as it is
rebase → Makes history clean and linear
Git is more than just a tool — it’s the base of teamwork, automation, and deployment in DevOps.
If you learn Git well, you’ll be ready for real DevOps workflows.
📢 Next Blog → We’ll dive into CI/CD — the automation magic that takes your code from Git to live production without you lifting a finger.



