Git · Practice test and quiz · Updated November 2026
A Git practice test checks whether you can use Git with confidence: staging and committing, branching and merging, rebasing, working with remotes, and getting lost work back with git reflog. The Git project does not offer a certification, so a good Git quiz follows the official Git reference manual for current Git 2.x rather than an exam blueprint; the closest certificate is GitHub Foundations (GH-900). This guide covers what to study, who it suits and a two-to-three-week plan. It ends with 10 free Git practice questions with answers and explanations, useful for self-checks and Git interview preparation.
At a glance
| Topic | Git version control, current Git 2.x |
| Latest Git release | 2.56.0 (28 September 2026) |
| Official certification | None from the Git project |
| Closest certification | GitHub Foundations (GH-900) |
| Free in this post | 10 practice questions with answers |
| Exametics set | 5 practice tests, 240 questions |
- Expect recovery scenarios: a bad reset, a broken rebase or a commit that must be undone on a shared branch.
Source: Git reference manual on git-scm.com and the Pro Git book, “What is Git?”. Checked on 9 November 2026.
What a good Git practice test covers
A good Git practice test covers the Git model, staging and committing, branching and merging, rebasing, remotes, undoing changes, recovery, stash and worktrees, and configuration. It asks what each command changes, not just what it is called.
The Git model: three states and three areas
The Pro Git book describes three states for a file: modified, staged and committed. “Staged means that you have marked a modified file in its current version to go into your next commit snapshot.”
Those states map to three areas: the working tree, the staging area (also called the index) and the Git directory, which holds the object database. Know which area each command touches and most “what happens next?” questions become easy.
Staging, committing and amending
For example, git commit -a stages modified and deleted files, but the Git manual says “new files you have not told Git about are not affected”.
You should also know that git commit --amend replaces the tip of the branch with a new commit. The manual warns you to understand the effect of rewriting history if that commit has already been published.
Branching, merging and revisions
Branch questions test git switch, git branch -d and the three merge modes. A fast-forward merge only moves the branch pointer. --no-ff always creates a merge commit, and --ff-only refuses to merge when a fast-forward is not possible.
Revision syntax is a common source of trick questions. According to the gitrevisions manual, HEAD^2 is the second parent of a merge commit, while HEAD~2 is the grandparent reached by following first parents. A..B lists commits reachable from B but not from A, and A...B lists commits reachable from either side but not both.
| Merge option | What it does |
|---|---|
--ff (default) | Fast-forwards when possible; otherwise creates a merge commit |
--no-ff | Always creates a merge commit |
--ff-only | Fast-forwards when possible; otherwise refuses and exits with a non-zero status |
--squash | Stages the combined result but makes no commit and records no merge |
Rebasing and rewriting history
Interactive rebase questions test detail. You should know what pick, reword, edit, squash, fixup and drop do, and how --autosquash uses commits whose messages start with “fixup! ” or “squash! ”.
The git-rebase manual also says rebasing a branch “that others have based work on is a bad idea”.
Remotes and collaboration
Remote questions test the difference between git fetch, which updates remote-tracking branches, and git pull, which fetches and then integrates the upstream branch into your current branch.
The git-push manual says a plain --force “can cause the remote repository to lose commits”. --force-with-lease is the safer choice, because the push fails if the remote branch no longer matches your remote-tracking branch.
Undoing changes: reset, revert and restore
The table summarises the official manual pages.
| Command | What it changes |
|---|---|
git reset --soft | Moves the branch; leaves the index and working tree unchanged |
git reset --mixed (default) | Moves the branch and resets the index; leaves the working tree unchanged |
git reset --hard | Moves the branch and overwrites the index and working tree |
git revert | Records a new commit that reverses an earlier one; history is kept |
git restore | Restores files in the working tree (or the index with --staged); makes no commit |
Recovery and investigation
The git-reflog manual says reflogs “record when the tips of branches and other references were updated in the local repository”. So it can find commits that seem lost after a bad reset. By default, reflog entries expire after 90 days, or 30 days for entries that are no longer reachable.
git bisect uses a binary search to find the commit that introduced a bug. With git bisect run, your script exits with 0 for a good commit, 1 to 127 (except 125) for a bad one, and 125 to skip a commit that cannot be tested. git cherry-pick copies an existing commit’s change onto your branch as a new commit.
Stash, worktrees and submodules
git stash saves your local changes and returns the working tree to HEAD. Untracked files are stashed only with -u (or -a, which also stashes ignored files), and pop removes the entry from the stash list while apply keeps it.
Worktrees let one repository check out more than one branch at a time. By default, git worktree add refuses a branch that is already checked out in another worktree. Submodules are separate repositories inside a project, and git submodule update checks out the commit recorded in the parent project on a detached HEAD.
Configuration and .gitignore
Git reads configuration from the system file, your global files and the repository’s own file, in that order, and the last value found wins. By default, git config writes to the repository file.
The gitignore manual is clear that files already tracked by Git are not affected by .gitignore. To stop tracking one, you remove it from the index with git rm --cached. A trailing slash matches only directories, and you cannot re-include a file if its parent directory is excluded.
Exametics practice tests
Git Practice Tests
- 5 practice tests with 48 questions each: 240 questions in total
- A timed Exam Mode test
- Every answer explained, with a hint, and tagged with one of nine topic areas
- Lifetime access
30-day refund. Instant access after payment.
Who these Git practice tests are for
These Git practice tests are for developers, DevOps engineers, QA engineers and students who want to check how well they really know Git. They work as a knowledge check and as preparation for Git interview questions, and they are not a copy of any vendor exam.
The Exametics series was rebuilt in November 2026 against the official Git documentation.
What each level should know
A sensible target for each stage (a study guide, not an official standard):
| Level | You should be able to |
|---|---|
| Beginner or student | Explain the three states, stage and commit, create and switch branches, push and pull, write a .gitignore |
| Working developer or QA engineer | Choose between merge and rebase, resolve conflicts, use reset, revert and restore correctly, tidy commits with interactive rebase |
| Senior developer or DevOps engineer | Recover with reflog, find regressions with bisect, backport with cherry-pick, run worktrees and submodules, set team rules for force-pushing |
Git practice tests vs the GitHub Foundations exam: which first?
Practise Git first if your basics are shaky, then take GitHub Foundations (GH-900), the closest official certificate, once they are solid. Git comes first because Microsoft Learn says GH-900 candidates should have foundational knowledge that “includes understanding Git”.
| Item | Git practice tests | GitHub Foundations (GH-900) |
|---|---|---|
| Focus | Git commands and workflows, from basics to recovery | Git and GitHub basics, repositories, collaboration, project management, security and community |
| Certificate | No; knowledge check and interview preparation | Yes; beginner level, does not require renewal |
| Time | Self-paced, plus a timed Exam Mode test | 100 minutes, proctored |
| Questions and passing score | 240 practice questions in 5 tests | Not published on the certification page |
| Cost and booking | One purchase, lifetime access | Price depends on the country or region; booked through Pearson VUE |
Next on your Git and GitHub path
- GitHub Foundations practice tests: the next step if you want a GitHub certificate. Read the GitHub Foundations exam guide first.
- GitHub Actions practice tests: for automating builds and tests once your Git workflow is solid (see the GitHub Actions exam tips).
- Linux command line practice tests: most Git work happens in a terminal (see the Linux command line guide).
How to prepare with Git practice tests in 2–3 weeks
Two to three weeks of about an hour a day in a test repository is a realistic plan to prepare for a Git practice test. Run every command you read about and check the result with git log --oneline --graph.
- Days 1–3: the model and daily commands Read the Pro Git chapter on what Git is. Practise add, commit, status, diff, log, switch and branch until you can predict what each one changes.
- Days 4–6: merging and remotes Create and resolve conflicts on purpose, compare fetch and pull, and try each merge mode.
- Days 7–9: undoing and rewriting Use reset in all three modes, revert, restore and commit –amend. Tidy a branch with interactive rebase, then abort a rebase halfway to see what happens.
- Days 10–12: recovery and advanced tools “Lose” commits with a hard reset and get them back from the reflog. Run bisect on a small script, cherry-pick a fix, and add and remove a worktree and a submodule.
- Days 13–15: test yourself Work through the Exametics Git practice tests and repeat every command you got wrong.
- Days 16–18: timed run Take the timed Exam Mode test. For interviews, explain each answer out loud.
Tip
Keep a throwaway repository for practice, and note git log --oneline -5 before any risky command so you can check your recovery.
Planning more than one exam?
If GitHub Foundations, GitHub Actions or a DevOps certification is also on your list, the All-Access Pass covers every practice test on Exametics, including new exams as they are added, with lifetime access. It costs less than buying about six single practice tests.
Free Git practice questions (10 with answers)
Try these 10 free practice questions as a short Git quiz to see where you stand. They are original sample questions written for this post and labelled by topic; the full Exametics Git practice tests have 240 more, each with an explanation and a hint.
Practice question 1 · Staging and committing
You edit the tracked file README.md and create a new file notes.txt that you have never added. You then run git commit -a -m "Update docs". What does the new commit contain?
- A. The changes to README.md and the new notes.txt
- B. Only the changes to README.md; notes.txt stays untracked
- C. Nothing, because
-acannot be combined with-m - D. Only notes.txt, because new files are staged first
Show answer
Answer: B. The -a option stages files that have been modified or deleted, but the Git manual says new files you have not told Git about are not affected. A is wrong because notes.txt was never added. C is wrong because -a and -m are often used together. D is wrong because -a never stages untracked files.
Practice question 2 · Undoing changes
Your last three local commits should have been one commit. You have no other staged changes. Which approach moves the branch back while keeping all the changes from those commits staged, ready for one new commit?
- A.
git reset --hard HEAD~3, thengit commit - B.
git revert HEAD~3, thengit commit - C.
git reset --mixed HEAD~3, thengit commit - D.
git reset --soft HEAD~3, thengit commit
Show answer
Answer: D. --soft moves the branch but leaves the index and working tree unchanged, so the combined changes stay staged; the git-reset manual gives this exact use. A is wrong because --hard overwrites the working tree and the changes are gone. B is wrong because revert adds a new commit that reverses a change instead of combining commits. C is wrong because --mixed resets the index, so nothing is staged and the plain commit would have nothing to record.
Practice question 3 · Undoing changes
A commit you pushed to the shared main branch yesterday introduced a bug. Several teammates have already pulled it and built on it. What is the safest way to undo its effect?
- A. Run
git reverton that commit and push the new commit - B. Run
git reset --hardto the commit before it and force-push - C. Drop the commit with an interactive rebase and force-push
- D. Run
git restoreon the affected files and push
Show answer
Answer: A. git revert records a new commit that reverses the earlier one, so shared history is not rewritten and teammates can simply pull. B and C rewrite published history, which the git-rebase manual calls a bad idea, and git-push warns a force-push can make the remote lose commits. D is wrong because restore changes files but makes no commit, so there is nothing to push.
Practice question 4 · Branching and merging
You are on main. Both main and feature have new commits that the other branch does not have. What happens when you run git merge --ff-only feature?
- A. Git creates a merge commit, because a fast-forward is not possible
- B. Git fast-forwards main to feature and drops main’s extra commits
- C. Git refuses to merge and exits with a non-zero status
- D. Git rebases main onto feature automatically
Show answer
Answer: C. The git-merge manual says that with --ff-only, when a fast-forward is not possible, Git refuses to merge and exits with a non-zero status. A describes the default --ff behaviour, not --ff-only. B is wrong because a fast-forward never discards commits; it is only possible when the current branch is an ancestor. D is wrong because merge never runs a rebase.
Practice question 5 · Rebasing and rewriting history
In an interactive rebase todo list, you want to fold the commit “Fix typo” into the commit above it and throw away the message “Fix typo”. Which command should replace pick on the “Fix typo” line?
- A.
squash - B.
fixup - C.
reword - D.
drop
Show answer
Answer: B. fixup folds the commit into the previous one, and the git-rebase manual says the messages of fixup commits are omitted from the suggested message. A is wrong because squash also folds the commit but keeps its message in the combined message. C is wrong because reword only edits a commit message. D is wrong because drop removes the commit and its changes.
Practice question 6 · Recovery
You meant to run git reset --hard HEAD~1 but typed HEAD~3. The three commits were never pushed, and you have run no other commands since. How can you get them back?
- A. Check
git reflog, then rungit reset --hard HEAD@{1} - B. Run
git revert HEAD~3 - C. Run
git fetchand merge the remote branch - D. Run
git stash pop
Show answer
Answer: A. The reflog records each update to HEAD in your local repository, and HEAD@{1} means where HEAD was one move ago, which is just before the reset. B is wrong because revert creates a new commit reversing a change; it does not bring back lost commits. C is wrong because the commits were never pushed, so the remote does not have them. D is wrong because a reset does not create stash entries.
Practice question 7 · Remotes
You rebased your feature branch, which you had already pushed. A teammate may have pushed to the same remote branch since your last fetch. Which push replaces the remote branch only if it still matches your remote-tracking branch?
- A.
git push --force - B.
git push -u origin feature - C.
git push --no-verify - D.
git push --force-with-lease
Show answer
Answer: D. Used on its own, --force-with-lease requires the current value of each remote ref to equal your remote-tracking branch, so the push fails if a teammate has added commits you have not fetched. A is wrong because --force skips that check and can lose commits. B is wrong because a non-forced push of rewritten history is rejected, and -u only sets the upstream. C is wrong because --no-verify only skips the pre-push hook and does not allow a non-fast-forward update.
Practice question 8 · Recovery
You run git bisect run ./check.sh. Some commits in the range do not build, so they cannot be tested. Which exit code should check.sh return for those commits so that Git skips them?
- A. 0
- B. 1
- C. 125
- D. 128
Show answer
Answer: C. The git-bisect manual reserves exit code 125 for code that cannot be tested, and Git skips that revision. A is wrong because 0 marks the commit as good. B is wrong because 1 to 127, except 125, marks it as bad. D is wrong because any code outside those ranges, such as 128, aborts the bisect session.
Practice question 9 · Stash and worktrees
You have half-finished, uncommitted work on feature. An urgent fix is needed on a new branch from main, and you do not want to stash or commit your work. Which command lets you work on both at once?
- A.
git worktree add -b hotfix ../hotfix main - B.
git switch -c hotfix main - C.
git worktree add ../feature-copy feature - D.
git stash apply
Show answer
Answer: A. A worktree lets one repository check out more than one branch at a time, so this creates a new hotfix branch from main in a separate folder and leaves your feature work untouched. B switches the current working tree, which either carries your uncommitted changes across or refuses if they would be lost. C is refused by default because feature is already checked out in another worktree. D applies an existing stash; it does not create a second working tree.
Practice question 10 · Configuration and .gitignore
You add config.env to .gitignore, but git status still shows changes to it. The file was committed months ago. What is the cause and the fix?
- A. The pattern needs a trailing slash: write
config.env/ - B. Tracked files are not affected by .gitignore; run
git rm --cached config.envand commit - C. .gitignore only takes effect after you commit the .gitignore file
- D. Add
!config.envso Git stops tracking it
Show answer
Answer: B. The gitignore manual says files already tracked by Git are not affected and recommends git rm --cached to remove the file from the index while keeping it on disk. A is wrong because a trailing slash makes the pattern match only directories, so it would not match this file. C is wrong because Git reads .gitignore from the working tree before it is committed, and committing it would not untrack the file anyway. D is wrong because ! negates a pattern and re-includes files instead of ignoring them.
How did you score?
8–10 correct: your Git is in good shape, so try a full timed test next. Under 8: note the topic of each miss and practise those commands in a test repository first. The Exametics Git practice tests have 240 more questions like these, each with an explanation, a hint and its topic area.
Common Git mistakes these questions catch
Most Git mistakes come from not knowing which area a command changes: the working tree, the index, a branch or the remote. Practice questions catch these six often.
- Using reset when you need revert. Reset moves a branch and can rewrite shared history; revert adds a new commit and is safe on shared branches.
- Force-pushing without a lease. A plain
--forcecan delete a teammate’s commits from the remote. Use--force-with-leaseinstead. - Thinking .gitignore untracks files. It only affects untracked files; tracked files need
git rm --cached. - Forgetting the reflog. After a bad reset or rebase, commits usually still exist locally and the reflog shows where they are.
- Mixing up
^and~.HEAD^2is a merge commit’s second parent;HEAD~2is two first-parent steps back. - Expecting stash to save new files. Untracked files are stashed only with
-uor-a.
Git practice test FAQs
Is there an official Git certification?
The Git project does not offer a certification exam. The closest official option is GitHub Foundations (GH-900), which Microsoft Learn says includes understanding Git as part of wider GitHub fundamentals.
Are there free Git practice questions?
Yes. This post has 10 free Git practice questions with answers and explanations, which work as a short Git practice test. The full Exametics Git practice tests add 240 more questions across 5 tests, each with an explanation and a hint.
How many questions are in the Exametics Git practice tests?
There are 5 practice tests with 48 questions each, 240 questions in total, including a timed Exam Mode test. Every question is tagged with one of nine topic areas.
Which Git version do the practice questions follow?
The series was rebuilt in November 2026 against the official Git documentation for current Git 2.x, and command behaviour was checked on Git 2.55. The git-scm.com home page lists 2.56.0, released on 28 September 2026, as the latest Git release.
Is Git hard to learn, and how long should I prepare?
The daily commands are quick to learn, but undoing changes, rebasing and recovery take practice. About two to three weeks of an hour a day in a test repository is a realistic plan to close the gaps a Git practice test shows.
Should I practise Git or take GitHub Foundations first?
Practise Git first if your basics are shaky, because Microsoft Learn says GitHub Foundations candidates need foundational knowledge that includes understanding Git. Then move on to GitHub Foundations if you want a certificate.
Are the Git practice tests online?
Yes. The Exametics Git practice tests are online with instant access after payment, and the set includes a timed Exam Mode test. By comparison, Microsoft Learn says the GitHub Foundations exam is proctored, lasts 100 minutes and is booked through Pearson VUE.
Official documentation: Git reference manual (git-scm.com) and GitHub Foundations certification on Microsoft Learn. Checked on 9 November 2026.
Take the full Git practice test: 240 explained questions
Work through 5 Git practice tests, see why every answer is right or wrong, and finish with a timed Exam Mode test.
✓ Every answer explained · ✓ Timed exam mode · ✓ 30-day refund