⚡ 52 Live Scenarios
🎯 STAR Method Answers📋 60s Elevator Pitches
Git is the indisputable standard for source code control and version management across the global software engineering industry, underpinning all collaborative delivery and GitOps workflows. While junior engineers rely on basic push and pull commands, senior engineers and DevOps architects must master Git's underlying content-addressable object database, including blobs, trees, commits, and cryptographic tag signatures. Interviewers test your proficiency in handling complex, high-pressure version control emergencies: surgically recovering detached HEAD commits and orphaned branches with git reflog, performing non-destructive interactive rebases across divergence-heavy enterprise release branches, and bisecting production regressions across thousands of commits. You will also be evaluated on designing trunk-based branching strategies, managing multi-tier Git submodules, structuring monorepos, and establishing pre-commit security hooks to prevent confidential credential leaks. Dive into our scenario-based Git questions to sharpen your terminal recovery skills, internal object comprehension, merge conflict resolution strategies, commit signing workflows, and enterprise-grade repository governance standards. Whether preparing for Staff DevOps discussions or lead engineer interviews, these step-by-step incident solutions provide the architectural clarity and hands-on CLI commands needed to resolve repository crises with complete confidence.
Get 1 Git & Branching Workflows interview question in your inbox every week
Preparing for a cloud or platform interview? Subscribe to get our weekly deep-dive scenario plus instant access to the Top 50 Kubernetes Interview Questions & Incident Runbooks PDF.
gitignore only prevents *new* files from being tracked. It does not untrack files that are already in the repo. Git is still watching config.yaml because it was...
Troubleshooting guide for Git detached HEAD state: understanding HEAD pointing to a commit instead of a branch, commit recovery via branch creation and git refl...
You can't reset main — it's shared and 15 other commits have built on top. The right tool is git revert, which creates a *new* commit that undoes the ...
git pull is two commands stitched together: git fetch (download new commits and tags from the remote into origin/) followed by git merge origin/ into your curre...
Compliance auditors essentially want to see: every change to main is reviewed by someone other than the author, every change is traced to a ticket, every change...
git subtree embeds the contents of another repository directly into a subdirectory of your main repository without detached HEAD states, submodules initializati...
git fetch downloads new commits, branches, and tags from the remote into your local remote-tracking branches (e.g., origin/main) but does not touch your working...
rerere stands for "reuse recorded resolution." When enabled (git config --global rerere.enabled true), Git silently records how you resolved each merg...
Git does not track empty directories. If you create logs/ with nothing in it and run git add logs/, nothing happens — Git has nothing to track because the direc...
Deleting a file in a new commit does not remove it from history. Git stores every version of every file as an immutable blob object. The 500 MB blob is still in...
Git is fundamentally a content-addressable filesystem. Every piece of data is stored as an object identified by its SHA-1 (or SHA-256) hash. There are four obje...
Git has three important snapshots: the last commit (HEAD), the staging area (index), and the working directory. Each diff variant compares two of these:....
Git can't merge binary files — there's no line-by-line diff. When both branches modify the same binary file, Git marks it as conflicted and keeps both...
Mastering Git refspecs: anatomy of source and destination ref mappings, the plus (+) force update flag, shallow clones, and custom refspecs in GitLab/GitHub Act...
mailmap is a file that maps different author names and emails to a canonical identity. It fixes inconsistencies in git log, git shortlog, and git blame without ...
git fsck (file system check) verifies the integrity of the Git object database — it walks every object and checks that nothing is corrupted, missing, or orphane...
Practical runbook for discarding local Git modifications: unstaged edits in the working directory, staged files in the index, and untracked files/directories us...
Key incident runbooks, interview talking points, and architecture tradeoffs.
You started coding directly on `main` and made three commits. You realize this work belongs on a feature branch and you haven't pushed yet. How do you move those commits to a new branch and clean up `main`?
"In a fast-paced team with dozens of pull requests merged daily, Git workflow hygiene was critical. The interviewer is testing: Basic branch mechanics, understanding that branches are just movable pointers to commits.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third."
Key Architectural Takeaway: Pro-Tip: Create the feature branch from where you are right now — this captures your three commits on the new branch:.
What is the difference between `git clone` and `git fork`, and when would you use each in practice?
"When an engineer accidentally creates this branch or commit divergence, I walk them through safe recovery without data loss. The interviewer is testing: Understanding of remote workflows and contribution models.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third."
Key Architectural Takeaway: Pro-Tip: Clone (git clone ) — downloads a copy of a repo to your laptop. You get the full history and a remote called origin pointing back .
You ran `git merge` and Git stopped with conflicts in three files. Walk me through exactly how you resolve them, and explain what the conflict markers mean.
When resolving <strong>git merge conflicts</strong> across multiple files, senior engineers follow a disciplined runbook: inspect modified files with git status, analyze conflict markers using the 3-way merge ancestor, test changes locally, and finalize the merge. Interviewers test whether you understand Git internals—such as common ancestors, diff3 markers, and git rerere—or whether you treat merge conflicts as guesswork.
Key Architectural Takeaway: Pro-Tip: Always configure 'git config --global merge.conflictstyle zdiff3'. Viewing the common base ancestor turns conflict resolution from blind guesswork between two divergent commits into a clear three-way diff where the intent of both engineers is immediately visible.
When should you use `git rebase` instead of `git merge`, and what is the one rule you must never break?
"Git is an immutable directed acyclic graph (DAG); knowing commands like git reflog means you never truly lose commits. The interviewer is testing: Workflow tradeoffs, understanding the danger of rewriting shared history.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third."
Key Architectural Takeaway: Pro-Tip: Merge preserves the actual branching history (creates a merge commit). Good for main/release branches where the history of *when t.
You have local changes in your working directory that you don't want anymore. How do you discard them, and what's the difference between discarding tracked vs untracked changes?
"In a fast-paced team with dozens of pull requests merged daily, Git workflow hygiene was critical. The interviewer is testing: Understanding of the working tree, staging area, and untracked files.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third."
Key Architectural Takeaway: Pro-Tip: Modified tracked files (not staged): git restore (or older syntax git checkout -- ) reverts the file to what's in HEAD..
🌐
Explore Related DevOps & Cloud Domains
Cross-train across interconnected systems for senior and staff infrastructure rounds.
Master Git & Branching Workflows & Platform Engineering In Production
Preparing for a cloud or platform interview? Subscribe to get our weekly deep-dive scenario plus instant access to the Top 50 Kubernetes Interview Questions & Incident Runbooks PDF.