10 Git & GitHub Scenarios for DevOps Engineers

10 Git & GitHub Scenario Questions Every DevOps Engineer Should Know (With Answers) 1. You pushed secrets to GitHub. What’s your first move? Ans: Rotate the secret immediately. Deleting the file doesn’t help, Git history already has it. Then remove it from history using tools like git filter-repo or BFG and add secrets scanning. 2: Two teams merged to main and prod is broken. What do you do? Ans: Revert the bad commit(s), don’t rewrite history. Git revert creates a clean rollback and keeps the audit trail intact. 3. Your pipeline fails after a merge. How do you find the broken commit fast? Ans: Use git bisect. It’s faster than guessing and shows you exactly where things went wrong. 4. You committed directly to main. Now what? Ans: Revert the commit and move the work into a proper branch. Then protect main with branch rules so it doesn’t happen again. 5. Someone force-pushed and wiped commit history. Can you recover it? Ans: Yes. Use git reflog. Git tracks where HEAD has been even mistakes leave footprints. 6. You need to deploy a hotfix without unfinished features. How? Ans: Create a hotfix branch from the last stable tag. Fix → test → deploy → merge back into main and develop. 7. Your PR has 30 messy commits. How do you clean it up? Ans: Interactive rebase (git rebase -i). Squash the noise. A clean history helps future debugging and onboarding. 8. CI works locally but fails on GitHub Actions. Where do you look first? Ans: Environment differences. OS, env vars, permissions, missing secrets, logs will tell the story. 9. A contractor needs access, but you don’t trust full permissions. What do you do? Ans: Use GitHub teams and least-privilege access. Read-only or specific repo permissions. Security is DevOps responsibility. 10. You want every merge to trigger tests and deployments automatically. How? Ans: GitHub Actions with branch protection rules. No green pipeline = no merge. Automation enforces discipline. #DevOps #Git #GitHub #CI_CD #CloudEngineering #SRE #TechCareers

To view or add a comment, sign in

Explore content categories