Interview question bank

Git Interview Questions and Answers

51 Git interview questions, each with a short answer you can say in the interview, a detailed explanation, a real-world example and an interview tip; 23 of them are marked as frequently asked. Freshers can start with the first section; experienced testers can jump to the harder questions.

Git interview questions for freshers

Beginner3 Years Frequently asked

1. Difference between git merge and git rebase in an automation repo?

Answer: Merge preserves history with a merge commit; rebase replays your commits on top of the target for a linear history. Rebase local branches, merge shared ones.

Detailed explanation, example and interview tip

For automation repos with many contributors, feature branches rebased onto main keep the history readable and make bisecting a flaky-test regression far easier. Never rebase a branch others have pulled.

Real-world example

Bisecting to find which commit introduced a flaky wait is trivial on linear history.

Interview tip

The golden rule line: 'never rebase public/shared branches'.

Beginner3 Years Frequently asked

2. What is working tree and index, and why does it matter in Git?

Answer: working tree and index is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of working tree and index should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used working tree and index to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Beginner5 Years Frequently asked

3. What is cherry-pick, and why does it matter in Git?

Answer: cherry-pick is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of cherry-pick should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used cherry-pick to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Beginner7 Years Frequently asked

4. What is remote tracking branches, and why does it matter in Git?

Answer: remote tracking branches is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of remote tracking branches should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used remote tracking branches to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Beginner10+ Years Frequently asked

5. What is submodules, and why does it matter in Git?

Answer: submodules is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of submodules should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used submodules to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Beginner3 Years

6. How would you apply branches in a production Git project?

Answer: Apply branches through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that branches controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused branches check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing branches.

Beginner3 Years

7. What is merge, and why does it matter in Git?

Answer: merge is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of merge should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used merge to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Beginner3 Years

8. How would you apply merge conflicts in a production Git project?

Answer: Apply merge conflicts through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that merge conflicts controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused merge conflicts check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing merge conflicts.

Beginner5 Years

9. How would you apply interactive rebase in a production Git project?

Answer: Apply interactive rebase through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that interactive rebase controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused interactive rebase check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing interactive rebase.

Beginner5 Years

10. What is stash, and why does it matter in Git?

Answer: stash is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of stash should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used stash to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Beginner5 Years

11. How would you apply tags in a production Git project?

Answer: Apply tags through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that tags controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused tags check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing tags.

Beginner7 Years

12. How would you apply force push safety in a production Git project?

Answer: Apply force push safety through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that force push safety controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused force push safety check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing force push safety.

Beginner7 Years

13. What is squash merges, and why does it matter in Git?

Answer: squash merges is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of squash merges should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used squash merges to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Beginner7 Years

14. How would you apply hooks in a production Git project?

Answer: Apply hooks through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that hooks controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused hooks check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing hooks.

Beginner10+ Years

15. How would you apply branch protection in a production Git project?

Answer: Apply branch protection through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that branch protection controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused branch protection check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing branch protection.

Beginner10+ Years

16. What is trunk-based development, and why does it matter in Git?

Answer: trunk-based development is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of trunk-based development should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used trunk-based development to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Git interview questions for experienced testers

Intermediate5 Years Frequently asked

17. Merge vs rebase — what do you use on an automation repository?

Answer: Rebase your own feature branch onto main to keep a linear history, merge (with a PR) into main; never rebase a branch other people have already pulled.

Detailed explanation, example and interview tip

Merge preserves the true topology and creates a merge commit; rebase rewrites your commits on top of the target, giving a clean, reviewable history but new SHAs. For a test repo where many small branches touch shared page objects, rebasing before opening the PR dramatically reduces conflict noise. The rule that matters is ownership: rewriting shared history forces everyone else to recover with reset --hard, so rebase only unpushed or personal branches, and use --force-with-lease rather than --force when you must push a rebased branch.

bash
1git fetch origin
2git switch feature/checkout-tests
3git rebase origin/main # replay my commits on latest main
4# resolve conflicts, then
5git rebase --continue
6git push --force-with-lease # safe: fails if someone else pushed

Real-world example

A team rebased shared release branches and lost two days of work; switching to rebase-before-PR only ended the incidents.

Interview tip

--force-with-lease is the detail that marks experience — mention it by name.

Intermediate3 Years Frequently asked

18. How would you apply working tree and index in a production Git project?

Answer: Apply working tree and index through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that working tree and index controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused working tree and index check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing working tree and index.

Intermediate3 Years Frequently asked

19. How would you apply merge in a production Git project?

Answer: Apply merge through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that merge controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused merge check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing merge.

Intermediate3 Years Frequently asked

20. What is rebase, and why does it matter in Git?

Answer: rebase is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of rebase should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used rebase to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Intermediate5 Years Frequently asked

21. How would you apply cherry-pick in a production Git project?

Answer: Apply cherry-pick through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that cherry-pick controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused cherry-pick check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing cherry-pick.

Intermediate5 Years Frequently asked

22. How would you apply stash in a production Git project?

Answer: Apply stash through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that stash controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused stash check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing stash.

Intermediate5 Years Frequently asked

23. What is reflog, and why does it matter in Git?

Answer: reflog is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of reflog should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used reflog to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Intermediate7 Years Frequently asked

24. How would you apply remote tracking branches in a production Git project?

Answer: Apply remote tracking branches through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that remote tracking branches controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused remote tracking branches check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing remote tracking branches.

Intermediate7 Years Frequently asked

25. How would you apply squash merges in a production Git project?

Answer: Apply squash merges through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that squash merges controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused squash merges check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing squash merges.

Intermediate7 Years Frequently asked

26. What is bisect, and why does it matter in Git?

Answer: bisect is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of bisect should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used bisect to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Intermediate10+ Years Frequently asked

27. How would you apply submodules in a production Git project?

Answer: Apply submodules through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that submodules controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused submodules check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing submodules.

Intermediate10+ Years Frequently asked

28. How would you apply trunk-based development in a production Git project?

Answer: Apply trunk-based development through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that trunk-based development controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused trunk-based development check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing trunk-based development.

Intermediate10+ Years Frequently asked

29. What is pull request hygiene, and why does it matter in Git?

Answer: pull request hygiene is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of pull request hygiene should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used pull request hygiene to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Intermediate5 Years

30. How do you move one fix into another branch without merging everything?

Answer: git cherry-pick the specific commit (or range) onto the target branch; for a partial file change, commit the hunk separately first so there is a clean commit to pick.

Detailed explanation, example and interview tip

Cherry-pick copies the diff and creates a new commit with a new SHA, so the same change can exist on two branches — later merges may report it as already applied. Use -x to record the original SHA in the message for traceability, and pick ranges with A..B when a fix spans commits. When the pick conflicts, resolve then git cherry-pick --continue; abort restores the branch. Frequent cherry-picking usually signals a branching strategy problem worth fixing.

bash
1git log --oneline main -5
2git switch release/2.4
3git cherry-pick -x 9f2c1ab # copy the locator fix into the release branch
4# on conflict
5git status
6git add src/test/java/pages/CartPage.java
7git cherry-pick --continue

Real-world example

A stale-locator fix needed to reach a frozen release branch without pulling in unrelated new tests from main.

Interview tip

Mention -x for traceability and that repeated picks hint at a branching-model smell.

Intermediate7 Years

31. What branching strategy works for a shared automation repository?

Answer: Trunk-based: short-lived branches off main, PR review with the suite running in CI, squash merge, and release branches only when the product itself is branched.

Detailed explanation, example and interview tip

Test code changes constantly and is touched by many people, so long-lived branches guarantee painful conflicts in page objects and utilities. Keep branches under a day or two, protect main with required checks (compile, lint, smoke suite), and require review from someone who owns the affected area. Tag test-code versions alongside the application release they validate so you can reproduce a past run exactly. Mirror the app's branching only when tests must diverge for an in-support older release.

bash
1git switch -c feature/api-contract-tests origin/main
2# ... work, commit small, push
3gh pr create --fill --base main
4# CI: mvn -q clean verify -Pci -Dgroups=smoke
5git tag -a tests-2.4.0 -m "Suite validating app 2.4.0"
6git push origin tags/tests-2.4.0

Real-world example

Two testers refactored BasePage in parallel week-long branches; moving to short-lived branches plus required smoke checks removed the recurring conflicts.

Interview tip

Tie the strategy to CI gates — a strategy without required checks is just a naming convention.

Intermediate3 Years

32. What is commits, and why does it matter in Git?

Answer: commits is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of commits should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used commits to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Intermediate5 Years

33. What is revert versus reset, and why does it matter in Git?

Answer: revert versus reset is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of revert versus reset should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used revert versus reset to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Intermediate7 Years

34. What is fetch versus pull, and why does it matter in Git?

Answer: fetch versus pull is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of fetch versus pull should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used fetch versus pull to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Intermediate10+ Years

35. What is Git LFS, and why does it matter in Git?

Answer: Git LFS is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of Git LFS should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used Git LFS to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Advanced Git interview questions

Advanced7 Years Frequently asked

36. A commit broke the suite — how do you find and undo it?

Answer: git bisect to binary-search the first bad commit, then git revert it on main; use reset only on local, unpushed history.

Detailed explanation, example and interview tip

bisect run automates the search with a script that exits non-zero on failure, so finding the culprit across 200 commits takes about eight checkouts. revert creates a new commit that undoes the change, keeping history intact and safe for shared branches. reset --hard rewrites history and must never touch pushed commits others share. For a broken merge, revert -m 1 undoes it relative to the first parent.

bash
1git bisect start HEAD tests-2.3.0
2git bisect run mvn -q -Dtest=CheckoutTest test
3# git prints: <sha> is the first bad commit
4git bisect reset
5
6git revert 4d91c07 # safe on shared branches
7git revert -m 1 8ab3f21 # undo a merge commit

Real-world example

A silent wait-helper refactor broke 30 tests three days later; bisect run pinpointed the commit in under ten minutes.

Interview tip

Say 'revert on shared branches, reset only locally' — it is the answer interviewers listen for.

Advanced3 Years Frequently asked

37. What is branches, and why does it matter in Git?

Answer: branches is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of branches should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used branches to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Advanced5 Years Frequently asked

38. What is interactive rebase, and why does it matter in Git?

Answer: interactive rebase is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of interactive rebase should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used interactive rebase to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Advanced7 Years Frequently asked

39. What is force push safety, and why does it matter in Git?

Answer: force push safety is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of force push safety should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used force push safety to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Advanced10+ Years Frequently asked

40. What is branch protection, and why does it matter in Git?

Answer: branch protection is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of branch protection should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used branch protection to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Advanced3 Years

41. How would you apply commits in a production Git project?

Answer: Apply commits through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that commits controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused commits check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing commits.

Advanced3 Years

42. How would you apply rebase in a production Git project?

Answer: Apply rebase through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that rebase controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused rebase check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing rebase.

Advanced3 Years

43. What is merge conflicts, and why does it matter in Git?

Answer: merge conflicts is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of merge conflicts should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used merge conflicts to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Advanced5 Years

44. How would you apply revert versus reset in a production Git project?

Answer: Apply revert versus reset through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that revert versus reset controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused revert versus reset check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing revert versus reset.

Advanced5 Years

45. How would you apply reflog in a production Git project?

Answer: Apply reflog through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that reflog controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused reflog check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing reflog.

Advanced5 Years

46. What is tags, and why does it matter in Git?

Answer: tags is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of tags should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used tags to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Advanced7 Years

47. How would you apply fetch versus pull in a production Git project?

Answer: Apply fetch versus pull through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that fetch versus pull controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused fetch versus pull check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing fetch versus pull.

Advanced7 Years

48. How would you apply bisect in a production Git project?

Answer: Apply bisect through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that bisect controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused bisect check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing bisect.

Advanced7 Years

49. What is hooks, and why does it matter in Git?

Answer: hooks is a core Git concept used to make testing decisions more accurate, repeatable, and aligned with product risk.

Detailed explanation, example and interview tip

A strong explanation of hooks should cover its purpose, the problem it solves, when it is appropriate, and where it can mislead a team. In Git, use it deliberately rather than as a checklist item: connect it to observable behavior, choose clear pass/fail evidence, and record assumptions so another engineer can reproduce the result.

Real-world example

During release planning, the team used hooks to focus validation on the most important behavior and to communicate residual risk before deployment.

Interview tip

Answer in four parts: definition, suitable use case, limitation, and a concrete project example.

Advanced10+ Years

50. How would you apply Git LFS in a production Git project?

Answer: Apply Git LFS through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that Git LFS controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused Git LFS check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing Git LFS.

Advanced10+ Years

51. How would you apply pull request hygiene in a production Git project?

Answer: Apply pull request hygiene through an explicit, repeatable design: define the expected behavior, automate the highest-risk path, capture useful diagnostics, and verify the result against a stable oracle.

Detailed explanation, example and interview tip

In a production Git project, start by identifying the risk that pull request hygiene controls and the evidence needed to prove the behavior. Keep setup, action, verification, and cleanup separate; parameterize environment-specific values; and make failures explain the business impact. Run the smallest relevant check on each change, broader coverage in the pipeline, and review flaky or slow results rather than hiding them with retries.

Real-world example

A team introduced a focused pull request hygiene check at the layer closest to the risk, attached diagnostics to failures, and used the result as a release signal instead of relying on manual confirmation.

Interview tip

Describe one trade-off, one failure mode, and one measurable outcome when discussing pull request hygiene.

Interview questions by subject

Want to search across every subject? Open the full question bank.