Interview Q&A / Git & GitHub
Git & GitHub interview questions
Branching, merge vs rebase, resolving conflicts and pull requests, the way teams actually work.
Prefer rapid revision? Practise Git & GitHub short interview answers →
- What branching strategies do teams use in Git? Compare GitFlow and trunk-based development.
Most teams use short-lived feature branches merged through pull requests. GitFlow adds long-lived develop, release and hotfix branches and suits planned, versioned releases. Trunk-based development keeps everyone merging small changes into main at least daily, using CI and feature flags, and suits teams that deploy often.
AdvancedIn-depth3 min read - 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 - 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 - 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 - 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 - 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 - 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