Skip to main content

Command Palette

Search for a command to run...

Mastering Git — The Essential DevOps Skill

Published
4 min read
Mastering Git — The Essential DevOps Skill
V

👩‍💻 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:

  1. Edit files

  2. Stage changesgit add

  3. Save changesgit commit

  4. Send to remotegit push

  5. Merge 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

TermMeaning
Repository (Repo)A project with history of changes
CommitA saved version of code
BranchA separate copy for working on new changes
MergeCombine changes from different branches
CloneCopy a repo to your system
PullGet changes from remote
PushSend your changes to remote
Staging AreaPlace 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:

  1. Open the file

  2. Keep the correct changes

  3. Remove the markers

  4. Stage and commit again


Useful Git Commands for DevOps

CommandPurpose
git statusShow current state
git log --onelineShow commit history
git diffShow changes
git stashSave changes temporarily
git reset --hard commit_idGo back to a specific commit
git tagMark a version
git fetchGet changes without merging
git rebaseMove 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:

  1. Developer pushes code to GitHub

  2. CI/CD tool (Jenkins, GitHub Actions, etc.) detects the change

  3. Code is built, tested, and deployed automatically


Common Git Mistakes (and Fixes)

  • Pushing secrets → Use .gitignore

  • Forgetting to pull → Run git pull origin main before push

  • Working directly on main → Use feature branches

  • Overwriting history → Avoid git push --force unless 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.


More from this blog

The CloudOps Journal

10 posts