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. What does git restore do, and how is it different from git checkout for files?

    git restore discards changes in a file or unstages it. It was added in Git 2.23 to split the file-restoring job away from git checkout, which also switched branches and confused beginners.

    IntermediateQuick answer1 min read
  2. When would you use git restore instead of git reset?

    Use git restore to change files, either discarding edits or unstaging a path. Use git reset to move the branch pointer to another commit. Restore never moves your branch.

    IntermediateQuick answer1 min read