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 do you cherry-pick a range of commits, and what if there is a conflict?

    Use git cherry-pick A^..B to copy commits from A through B. On conflict, fix the files, git add them and run git cherry-pick --continue, or use --abort to cancel.

    IntermediateQuick answer1 min read
  2. What do --ours and --theirs mean when resolving a conflict?

    In a merge, ours is the branch you are on and theirs is the branch being merged in. git checkout --ours file or --theirs file takes that whole version of the file. In a rebase the meaning is reversed.

    IntermediateQuick answer1 min read
  3. What happens when a conflict occurs during a rebase, and how do you continue?

    Rebase stops at the commit that conflicts. You fix the files, git add them, and run git rebase --continue. You can skip that commit with --skip or give up entirely with --abort.

    IntermediateQuick answer1 min read