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 is the difference between git reset and git revert?

    git revert makes a new commit that undoes an earlier commit, so history is kept and it is safe on shared branches. git reset moves your branch pointer back to an older commit and removes the later commits from the branch; --soft keeps the changes staged, --mixed keeps them unstaged, and --hard throws them away. Use reset only on local, unpushed work.

    IntermediateIn-depth3 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