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 recover a branch that you deleted by mistake?

    Find the branch's last commit hash with git reflog, then recreate it with git branch name hash. The commits are not erased immediately, so recovery works until Git garbage-collects them.

    IntermediateQuick answer1 min read
  2. How can you turn a stash into its own branch?

    Run git stash branch new-name. Git creates the branch at the commit where you stashed, applies the stash there, and drops it, which avoids conflicts if the original branch has moved on.

    IntermediateQuick answer1 min read