Skip to main content

Command Palette

Search for a command to run...

Git Basics For Fresher DevOps

Updated
β€’3 min read
Git Basics For Fresher DevOps

Git Basics Every DevOps Fresher Should Know πŸš€

As a DevOps fresher, Git is one of the most important tools you must learn. In this short blog, I’ll share basic Git commands that helped me a lot.

πŸ”Ή What is Git?

Git is a distributed version control system used to track code changes.

πŸ”Ή Most Used Git Commands

  • git init – Initialize a repository

  • git status – Check file status

  • git add . – Stage changes

  • git commit -m "message" – Save changes

  • git push – Push code to GitHub

πŸ”Ή Why Git is Important for DevOps?

  • Helps manage infrastructure code

  • Supports CI/CD pipelines

  • Enables team collaboration

🎀 Advanced Mock Interview β€” Git & GitHub for DevOps (Senior Level)


Scenario 1 β€” Secret leaked AND forked

Interviewer:
A developer pushed a secret to GitHub. Before you noticed, someone forked the repo. What now?

You:
Rotate the secret immediately, invalidate the compromised credentials, then remove the secret from history. After that, treat the secret as fully compromised and monitor for abuse.

Explanation:
Forks copy history. You cannot guarantee deletion everywhere. Rotation is the only safe action.

Example:

git filter-repo --path .env --invert-paths
git push --force
aws iam delete-access-key
aws iam create-access-key

Scenario 2 β€” CI pipeline compromised

Interviewer:
Someone modified .github/workflows/deploy.yml to echo secrets into logs. What do you do?

You:
Disable pipeline, rotate all exposed secrets, audit logs, revert malicious commit, lock down workflow permissions.

Explanation:
CI has production access. Treat it as a security incident.


Scenario 3 β€” Git history rewritten in main

Interviewer:
Someone ran git push --force on main. Production is now inconsistent.

You:
Stop deployments, restore main from last known good commit or tag, communicate with team, enforce branch protection.


Scenario 4 β€” Partial deployment failure

Interviewer:
Your pipeline deploys to 5 regions. One region failed mid-deploy.

You:
Detect drift, rollback failed region or roll forward consistently.

Explanation:
Inconsistent versions cause data corruption.


Scenario 5 β€” GitOps controller outage

Interviewer:
ArgoCD is down and cannot sync infra. A critical change is needed.

You:
Apply emergency change manually, document it, reconcile back into Git once GitOps is restored.


Scenario 6 β€” Malicious PR with hidden intent

Interviewer:
A PR passes CI but secretly opens a backdoor in code.

You:
Use code review, static analysis, runtime security, principle of least privilege.


Scenario 7 β€” Repo with 2k commits slow

Interviewer:
Large monorepo is slow to clone.

You:
Use shallow clones, partial checkouts, split repo or use sparse checkout.


Scenario 8 β€” Accidental deletion of main

Interviewer:
Someone deleted the main branch.

You:
Restore from remote or GitHub UI, recreate protection.


Scenario 9 β€” Audit after breach

Interviewer:
Security asks: β€œWhich secrets were exposed in last 90 days?”

You:
Scan git history, logs, PRs, rotate all suspicious credentials.


Scenario 10 β€” GitHub outage during incident

Interviewer:
GitHub and registry are down; production is failing.

You:
Use last built artifact, emergency manual deploy, post-incident sync.


🧠 Deep Explanation Patterns

ConceptWhy Important
History rewriteCan destroy audit trail
Secrets in GitPermanent exposure risk
Branch protectionPrevents human error
GitOpsPrevents drift
CI securityCI has prod access
AuditabilityCompliance requirement

πŸ”₯ Key Interview Phrases

Use these:

  • β€œI treat this as a security incident.”

  • β€œFirst I contain the blast radius.”

  • β€œWe restore service before root cause.”

  • β€œWe prevent recurrence using automation.”


🟒 Final Tip

At senior level:
You are judged not on commands, but on:

  • Risk management

  • Blast radius control

  • Compliance & auditability

  • Team safety


DevOps Interview prep

Part 1 of 1

🎯 Who is this series for? Freshers aiming for DevOps / Cloud Engineer roles Students transitioning from Linux, Networking, or Development Anyone preparing for DevOps interviews from scratch