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 →
- How do you unstage a file you added by mistake?
Use git restore --staged file, or the older git reset HEAD file. The file leaves the staging area but your edits stay in the working directory.
BeginnerQuick answer1 min read - What is the difference between git diff and git diff --staged?
git diff shows changes in your working files that are not yet staged. git diff --staged shows changes already added to the staging area, which is exactly what the next commit will contain.
BeginnerQuick answer1 min read - What is the staging area in Git, and why does it exist?
The staging area (index) is a holding zone between your working files and the next commit. git add puts chosen changes there, so a commit contains exactly what you picked rather than everything you touched.
BeginnerQuick answer1 min read