INTERVIEW PREP
Interview questions
570 questions from real DevOps, SRE, platform engineering and MLOps interviews, with the answer an interviewer wants to hear. Try answering out loud first, then open the model answer.
Showing 1–15 of 20 questions
Learn Git →1.What is the difference between git fetch and git pull?Beginner
fetch downloads new commits and updates remote-tracking branches without touching your work. pull is fetch plus merge (or rebase) into the current branch.
2.What is the difference between merge and rebase?Beginner
Merge joins two histories with a merge commit and keeps history as it happened. Rebase replays your commits on top of another branch for a linear history, creating new commit IDs. Never rebase commits others have already pulled.
3.What is the difference between the working directory, the staging area and a commit?Beginner
The working directory is your files as they are now. git add copies changes to the staging area (the index), which is what the next commit will contain. git commit saves the staged snapshot into history.
4.What does .gitignore do, and why doesn't it ignore a file I already committed?Beginner
It tells Git which untracked files to leave out, like node_modules/ or .env. Files that are already tracked keep being tracked; remove them from the index with git rm --cached file, then commit.
5.What is the difference between git reset, git revert and git restore?Beginner
git restore throws away changes in files. git reset moves your branch back to an earlier commit (rewrites local history). git revert makes a new commit that undoes an old one, which is safe on shared branches.
6.What is a pull request (merge request), and why use one?Beginner
It is a request to merge one branch into another, with a place to review the diff, discuss it and run CI. It adds a quality gate and a record of why a change was made.
7.You committed a secret and pushed it. What do you do?Mid
Rotate the secret first, because it is already compromised. Then remove it from history (git filter-repo or BFG), force-push, ask collaborators to re-clone, and add secret scanning to prevent a repeat.
8.How do you undo a commit that is already on main?Mid
git revert <sha> creates a new commit that undoes it, which is safe on shared branches. reset --hard rewrites history and should only be used on private branches.
9.How do you find which commit introduced a bug?Mid
git bisect start, mark a bad and a good commit, and test each midpoint Git checks out; git bisect run ./test.sh automates it. It finds the culprit in log2(n) steps.
10.How do you resolve a merge conflict?Mid
Git marks the conflicting lines with <<<<<<<, ======= and >>>>>>>. Edit the file to the correct final version, remove the markers, git add it, then git commit (or git rebase --continue). Run the tests before pushing.
11.What does git stash do?Mid
It saves your uncommitted changes and gives you a clean working directory, so you can switch branches. git stash pop brings them back; git stash list shows saved stashes.
12.How do you squash several commits into one?Mid
Use an interactive rebase: git rebase -i HEAD~4 and mark commits as squash or fixup. Many teams use 'squash and merge' in the pull request instead. Only rewrite commits that aren't shared yet.
13.What is git cherry-pick and when is it useful?Mid
It copies one commit onto your current branch, for example to bring a hotfix from main into a release branch. Use it for a few commits; for many, merge or rebase instead.
14.What are Git hooks?Mid
Scripts Git runs at certain moments, such as pre-commit or commit-msg. Teams use them (often through the pre-commit framework) to run linters, formatters and secret scanners before code leaves a laptop. Enforce the same checks in CI too, because local hooks can be skipped.
15.What branching strategy would you choose and why?Senior
Usually trunk-based development: short-lived branches merged to main several times a day, feature flags for unfinished work, and releases cut from main with tags. GitFlow suits slow, versioned releases but adds merge overhead.