Practise Git & Version Control one question at a time. Answer out loud or in writing, get graded, and see exactly what you missed.
What is Git and how does it differ from centralized version control systems?
Git is a distributed version control system, so every clone holds the whole history. Centralized systems like Subversion or CVS keep the history on one server, and each client holds a working copy of the current files.
Git's history is local. You can commit, read the log, and compare versions with no network.
| Aspect | Git (distributed) | Centralized (SVN, CVS) |
|---|---|---|
| Full history | in every clone | on the server only |
| Commit and read history | local, no network | need the server |
| Branching | cheap and local | server-side, needs network |
| Server outage | any clone still has the full history | no commits until it returns |
The trade-off is that your commits stay private until you push, and teammates see them only after they fetch.
Missed:
“I'd run git reset --soft HEAD~1, which moves the branch back one commit but leaves all my changes staged, so I can fix things up and commit again. If I'd rather have the changes unstaged, a plain git reset HEAD~1 does the same thing, and I'd stay away from --hard because that throws the edits away.”
Knew itThey've got the soft reset keeping changes staged and the mixed-reset unstaged, and know to avoid --hard. A real interview would also want to hear how this differs from revert once a commit is pushed.
Missed: Doesn't mention that reset only rewrites local history, so a pushed commit should be undone with revert instead.
Get your own answers graded
Sign up free. Your account comes with 50 credits for grading, and it remembers what you missed.
What it covers
All 54 questions
Git basics and the staging area
What Git is, how it differs from GitHub and centralized systems, and how the index, staging and .gitignore decide what goes into a commit.
- What is Git and how does it differ from centralized version control systems?
- What is the difference between Git and GitHub, and why does it matter?
- What is the staging area, and why does Git separate it from commits?
- What is a .gitignore file, and how does Git decide what to ignore? Pro
- What is the index file, and how does it make git status fast? Pro
Branches, HEAD and tags
Branches as movable pointers, detached HEAD, lightweight versus annotated tags, and checking out several branches at once with worktrees.
- What is a branch in Git, and how do you create and switch one? Pro
- Is a Git branch really just a movable pointer to a commit? Pro
- What does detached HEAD mean, and how do you end up there? Pro
- What is the difference between lightweight and annotated tags, and when do you use each? Pro
- What is git worktree, and when would you use it? Pro
Merging and conflict resolution
Merge versus rebase, fast-forward and merge commits, how a three-way merge uses the merge base, and resolving conflicts, including with rerere.
- When should you use git merge versus git rebase to combine branches?
- How do you resolve a merge conflict, step by step, without panicking?
- What is the difference between a fast-forward merge and a merge commit? Pro
- What is git rerere, and how does it help with repeated conflict resolution? Pro
- How does a three-way merge work, and what is the merge base? Pro
Remotes, fetching and pushing
Clones, forks and bare repos, fetch versus pull, upstream tracking branches, refspecs, and force-pushing safely with --force-with-lease.
- What is the difference between git fetch and git pull?
- How do you clone a repository and connect it to a remote? Pro
- How does a fork differ from a clone, and how do you keep it in sync? Pro
- What is an upstream tracking branch, and how does it shape push and pull? Pro
- Why prefer git push --force-with-lease over a plain force push? Pro
- What is a bare repository, and why do servers host repos that way? Pro
- How do refspecs control what fetch and push actually map between repos? Pro
Undoing changes and recovery
Undoing commits and local edits with reset, revert, restore and stash, and getting lost work back with the reflog after a bad reset or rebase.
- How do you undo your most recent commit without losing the work?
- How do you throw away uncommitted local changes you no longer want? Pro
- What is the difference between reset --soft, --mixed, and --hard? Pro
- When do you reach for reset versus revert versus checkout? Pro
- What does git stash do, and when does it come back to bite you? Pro
- How does git reflog let you recover commits you thought were lost? Pro
- How do you recover cleanly after a rebase goes badly wrong? Pro
Rewriting history
Amend, cherry-pick and interactive rebase, why shared history should not be rewritten, and repo-wide rewrites such as scrubbing a leaked secret.
- When is git cherry-pick the right tool, and what are its dangers? Pro
- What can interactive rebase do, and how do you squash commits safely? Pro
- Why should you never rebase commits you have already pushed and shared? Pro
- What does git commit --amend do, and when is it unsafe? Pro
- How do you rewrite history across an entire repo, and what breaks downstream? Pro
- A secret got committed and pushed, how do you fully remediate it? Pro
Investigating history
Finding when and why code changed: git blame for a line's origin, git bisect to find a bad commit, and how Git detects renames.
Team workflows and safeguards
Branching strategies, pull request merge styles, long-lived branches, commit messages, hooks, and signed commits that keep a team's history trustworthy.
- What makes a good commit message, and why does it matter later? Pro
- Should you squash, merge, or rebase a pull request, and why? Pro
- How do Git Flow, GitHub flow, and trunk-based development differ? Pro
- What are Git hooks, and where do client-side and server-side ones differ? Pro
- How do you sign commits and verify who actually authored them? Pro
- How do you keep a long-lived feature branch healthy against a moving main? Pro
Object model and storage
Commits, trees and blobs as content-addressed snapshots, SHA hashing, loose objects and packfiles, and what git gc removes.
- What actually happens under the hood when you run git commit? Pro
- Is a Git commit a full snapshot or a diff, and why? Pro
- How do commits, trees, and blobs fit together in Git's object model? Pro
- How does Git store objects as loose files and later pack them? Pro
- How does Git hash content, and should you worry about SHA collisions? Pro
- What happens during git gc, and when can it delete unreachable commits? Pro
Scaling large repositories
Keeping big repos workable: monorepo performance, shallow and partial clones, Git LFS for binaries, and submodules versus subtrees.
All questions
Showing of 54What is Git and how does it differ from centralized version control systems?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Git is a distributed version control system, so every clone holds the whole history. Centralized systems like Subversion or CVS keep the history on one server, and each client holds a working copy of the current files.
Git's history is local. You can commit, read the log, and compare versions with no network.
| Aspect | Git (distributed) | Centralized (SVN, CVS) |
|---|---|---|
| Full history | in every clone | on the server only |
| Commit and read history | local, no network | need the server |
| Branching | cheap and local | server-side, needs network |
| Server outage | any clone still has the full history | no commits until it returns |
The trade-off is that your commits stay private until you push, and teammates see them only after they fetch.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the difference between Git and GitHub, and why does it matter?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Git is the version control program on your machine, and GitHub is a service that hosts Git repositories online and adds tools around them.
| Git | GitHub | |
|---|---|---|
| What it is | a command-line tool | a hosting service built on Git |
| Main features | git commit, git branch, git merge |
Pull requests, issues, code review |
| Where history lives | .git on your disk |
a hosted copy of the repository |
| Team extras | none built in | access control, Actions for CI |
It matters because Git works without GitHub. Your full history lives in .git on your disk, so you can work offline even when GitHub is down.
Switching hosts means pointing your remote, the address Git pushes to and fetches from, at a new URL. Git itself does not change, and hosts like GitLab or Bitbucket serve the same repositories.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the staging area, and why does Git separate it from commits?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
The staging area, or index, is where you build your next commit. git add copies a file's current content into the index. git commit turns whatever is staged into the new commit.
The separation lets you choose what goes in: the fix, not the debug print. git add -p goes further and lets you pick single hunks of one file.
git add stages the content, not the file, so edits made after it stay out of the commit until you add them again.
git diff # working files vs staging area
git diff --staged # staging area vs last commit
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How do you undo your most recent commit without losing the work?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
git reset --soft HEAD~1 undoes the last commit and keeps the changes staged, ready to commit again. Reset moves the branch pointer back one commit. Your files on disk never change.
git reset --soft HEAD~1 # commit undone, changes stay staged
git reset HEAD~1 # same, but changes end up unstaged
The default mode, --mixed, keeps the work unstaged instead. The --hard mode throws away your edits, so avoid it here.
Reset only moves your local branch, so use git revert HEAD for a commit you already pushed. Revert adds a new commit that undoes the old one, and nobody's history is rewritten.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
When should you use git merge versus git rebase to combine branches?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Use merge on shared branches. Use rebase to tidy your own branch before others pull it.
git merge records the join in a new commit and rewrites nothing, so merge is safe everywhere. The cost is a busier history, because every merge of diverged branches adds a merge commit.
git rebase replays your commits onto the other branch. The copies get new hashes, so they are new commits. Anyone who already had the old ones now holds a diverged branch, which is why you never rebase shared history.
| Concern | git merge |
git rebase |
|---|---|---|
| History | branch and join | one straight line |
| Existing commits | kept as they are | replaced by copies with new hashes |
| Conflicts | fixed once | can repeat per replayed commit |
A common workflow uses both. Rebase the feature branch onto the newest main, then merge it:
git switch feature
git rebase main # replay my commits on the newest main
git switch main
git merge feature # publish the finished work
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How do you resolve a merge conflict, step by step, without panicking?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Find the conflicted files, edit each one into the version you want, then git add them and commit. A merge conflict only means both branches changed the same lines. Git stops, keeps both versions in the file, and waits for you to decide. Nothing is lost.
Run git status first. It lists the conflicted files under Unmerged paths. Open each one. Your side sits between <<<<<<< HEAD and =======. The incoming side follows, up to >>>>>>> branch-name.
Edit the file into the text you want, then delete all three marker lines. Often the right result keeps parts of both sides.
git status # which files are unmerged
git add src/config.js # staging a file marks it resolved
git commit # finishes the merge
git merge --abort # bail out, back to before the merge
There is no separate "resolve" command. git add is the signal. Run the build and tests before committing, because a file with no markers left can still be broken. If it goes wrong, git merge --abort before the commit puts everything back as it was.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the difference between git fetch and git pull?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
git fetch only downloads new commits, while git pull downloads them and then integrates them into your current branch. Fetch updates your remote-tracking branches, local copies like origin/main. Fetch never changes your working files or your own branches, so it is always safe to run.
Pull integrates the upstream, the remote branch your branch tracks, and how it does that depends on your settings. By default current Git only fast-forwards, moving your branch ahead when you have no new commits of your own. A pull fails when your branch has diverged. git pull --rebase replays your commits on top instead, and git pull --no-rebase runs a merge. Set pull.rebase once to choose a default.
| Command | Updates origin/main |
Moves your branch | Can conflict |
|---|---|---|---|
git fetch |
yes | no | no |
git pull |
yes | yes | yes |
Fetching first lets you see what arrived before you decide how to combine it:
git fetch origin
git log --oneline main..origin/main # what arrived
git merge origin/main # the step git pull --no-rebase does for you
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is a branch in Git, and how do you create and switch one?
How do you throw away uncommitted local changes you no longer want?
What is a .gitignore file, and how does Git decide what to ignore?
How do you clone a repository and connect it to a remote?
What does git blame do, and when would you use it?
How does a fork differ from a clone, and how do you keep it in sync?
What makes a good commit message, and why does it matter later?
What actually happens under the hood when you run git commit?
Is a Git commit a full snapshot or a diff, and why?
How do commits, trees, and blobs fit together in Git's object model?
Is a Git branch really just a movable pointer to a commit?
What does detached HEAD mean, and how do you end up there?
What is the difference between reset --soft, --mixed, and --hard?
When do you reach for reset versus revert versus checkout?
What does git stash do, and when does it come back to bite you?
When is git cherry-pick the right tool, and what are its dangers?
What is the difference between a fast-forward merge and a merge commit?
What can interactive rebase do, and how do you squash commits safely?
Why should you never rebase commits you have already pushed and shared?
How does git reflog let you recover commits you thought were lost?
What is the difference between lightweight and annotated tags, and when do you use each?
What is an upstream tracking branch, and how does it shape push and pull?
Why prefer git push --force-with-lease over a plain force push?
What does git commit --amend do, and when is it unsafe?
Should you squash, merge, or rebase a pull request, and why?
How do Git Flow, GitHub flow, and trunk-based development differ?
What is git worktree, and when would you use it?
How does git bisect find a bad commit across thousands of revisions?
How do you recover cleanly after a rebase goes badly wrong?
Why do large binary files hurt a Git repo, and how does LFS help?
What are Git hooks, and where do client-side and server-side ones differ?
What is a bare repository, and why do servers host repos that way?
How does Git store objects as loose files and later pack them?
How does Git hash content, and should you worry about SHA collisions?
How does Git detect file renames when it stores no rename history?
What is the index file, and how does it make git status fast?
What is git rerere, and how does it help with repeated conflict resolution?
Submodules versus subtrees for vendoring code, what tradeoffs do you weigh?
How do you keep Git fast in a huge monorepo with millions of files?
What happens during git gc, and when can it delete unreachable commits?
When is a shallow or partial clone worth its later limitations?
How does a three-way merge work, and what is the merge base?
How do you rewrite history across an entire repo, and what breaks downstream?
How do you sign commits and verify who actually authored them?
A secret got committed and pushed, how do you fully remediate it?
How do refspecs control what fetch and push actually map between repos?
How do you keep a long-lived feature branch healthy against a moving main?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
Git & Version Control in pictures.
A quick recap of Git & Version Control in 32 short animated pictures, one idea at a time. About 8 min to get the whole topic back in your head before you walk in. Pause any picture, slow it down, or step through it.
Pro The first chapter is free to play. The other 29 pictures come with Pro.
Git & Version Control cheatsheet
- Under the hood01
- Stage & commit02
- Undo & rescue03
- Branch & stash04
- Merge & rebase05
- Remotes, push & pull06
- Investigate07
- Big repos & safety08
- The model09
- + 3 more inside
This picture is part of Pro. The first chapter is free to play; the other 29 pictures come with Pro.
Get Pro · $10/mo Already Pro? Sign in47 of 54 Git & Version Control answers are in Pro.
Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.
- Full answers + code
- AI explanations, simpler or deeper
- 1,000 AI credits / month
- Cancel anytime
Change topic
Pick a different technology or stack. Your current topic stays put until you choose a new one.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsDjango
Python Full-Stack DevelopmentRuby on Rails
Convention over ConfigurationServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQInterviewers also test these - they're common to every stack, whichever one you picked above.
FastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDInterviewers also test these - they're common to every stack, whichever one you picked above.
AI Engineer
LLMs, RAG, Agents, EvalsAI-Powered Developer
Claude Code, Copilot, Agentic WorkflowsCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.