Interview Q&A / Git & GitHub

INTERVIEW Q&A · 97 QUESTIONS

Git & GitHub interview questions

Branching, merge vs rebase, resolving conflicts and pull requests, the way teams actually work.

  1. How can you automate git bisect with a script?

    Use git bisect run with a command that exits 0 for good and non-zero (except 125) for bad. Git then runs it at each step and finds the culprit commit without manual answers.

    AdvancedQuick answer1 min read
  2. How do you cherry-pick a merge commit?

    Add -m 1 (or -m 2) to say which parent is the mainline, because a merge commit has two parents and Git cannot know which side's diff to copy.

    AdvancedQuick answer1 min read
  3. How do you remove a submodule properly?

    Run git submodule deinit -f path, then git rm -f path, and delete the leftover .git/modules/path folder. Commit the change. Just deleting the folder leaves stale configuration behind.

    AdvancedQuick answer1 min read
  4. What does git rebase --onto do?

    git rebase --onto newbase oldbase branch moves only the commits after oldbase onto a different base. It lets you transplant part of a branch, for example when a branch was started from the wrong parent.

    AdvancedQuick answer1 min read
  5. What does git revert -n (--no-commit) do?

    It applies the reverse of a commit to your working tree and index without committing. This lets you revert several commits and record them together as a single commit.

    AdvancedQuick answer1 min read
  6. What is git rerere?

    rerere means reuse recorded resolution. When enabled, Git remembers how you resolved a conflict and applies the same fix automatically if the same conflict appears again, such as during repeated rebases.

    AdvancedQuick answer1 min read