Skip to content
$ lynuxpro

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 46–60 of 490 questions

46.What is a pull request (merge request), and why use one?BeginnerGit

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.

47.You committed a secret and pushed it. What do you do?MidGit

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.

48.How do you undo a commit that is already on main?MidGit

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.

49.How do you find which commit introduced a bug?MidGit

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.

50.How do you resolve a merge conflict?MidGit

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.

51.What does git stash do?MidGit

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.

52.How do you squash several commits into one?MidGit

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.

53.What is git cherry-pick and when is it useful?MidGit

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.

54.What are Git hooks?MidGit

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.

55.What branching strategy would you choose and why?SeniorGit

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.

56.How do you recover a branch you deleted by mistake?SeniorGit

git reflog shows where HEAD has been; find the last commit of the branch and run git branch name <sha>. Commits stay recoverable until garbage collection prunes them.

57.How do you handle a huge repository that is slow to clone?SeniorGit

Use shallow clones (--depth 1) in CI, partial clones (--filter=blob:none) and sparse checkout for monorepos. Move large binaries to Git LFS or an artifact store, and clean old large files out of history with git filter-repo if needed.

58.What is trunk-based development, and what does it need to work?SeniorGit

Everyone merges small changes into main at least daily instead of keeping long-lived branches. It needs fast CI, good automated tests, feature flags to hide unfinished work, and code review that happens quickly.

59.How do you protect the main branch?SeniorGit

Use branch protection: no direct pushes, required pull request reviews (and CODEOWNERS), required passing CI checks, signed commits if needed, and no force pushes. Combine with secret scanning on push.

60.How does Git store data internally?SeniorGit

Git is a content-addressed store of objects: blobs (file content), trees (folders), commits (a tree plus parents and metadata) and tags. Each object is named by its hash. Branches are just files that point to a commit hash.