Git120 questions in the bank

Git Quiz: Test Your Git Knowledge

Pick how many questions you want, choose a difficulty and go. You'll see why each answer is right or wrong, then you can retry to beat your score.

Questions
Difficulty
Topic
Mode
  1. What kind of tool is Git?

    • A version control system
    • A code editor
    • A programming language
    • A web browser
  2. What is a repository?

    • A Git command
    • A website
    • A project folder that Git is tracking
    • A single file
  3. What's the relationship between Git and GitHub?

    • They're the same thing
    • Git tracks changes locally; GitHub hosts Git repositories online
    • GitHub is required to use Git
    • Git is a feature of GitHub
  4. Why should you set user.email before your first commit?

    • Git emails you a copy of each commit
    • It's needed to install Git
    • It sets your password
    • Every commit records its author's name and email
  5. Does Git need an internet connection to make commits?

    • Yes, always
    • Only for the first commit
    • No, commits are saved on your own computer
    • Only on Windows
  6. What does git init do?

    • Downloads a repository
    • Makes the first commit
    • Installs Git
    • Creates a new repository in the current folder
  7. What is the staging area?

    • The folder where you edit files
    • A copy of the repository online
    • The set of changes chosen for the next commit
    • The list of branches
  8. What does -m do in git commit -m "Fix typo"?

    • Gives the commit message on the command line
    • Merges the commit
    • Commits to the main branch
    • Commits only modified files
  9. What does "working tree clean" mean?

    • The repository has no commits
    • Git deleted your files
    • There are no changes that haven't been committed
    • All branches are merged
  10. What are Git's three areas?

    • Draft, final and published
    • The working directory, the staging area and the repository
    • Local, remote and cloud
    • Files, folders and branches
  11. Which key quits the git log view?

    • Q
    • Esc
    • Enter
    • X
  12. What does git show 3f9c2ab display?

    • The files in the folder
    • The details and changes of that one commit
    • Every commit after it
    • The branch it's on
  13. Why commit the .gitignore file itself?

    • So everyone working on the project ignores the same files
    • Git requires it
    • So the ignored files are backed up
    • It makes the repository smaller
  14. You committed secret.txt and then added it to .gitignore. What else must you do?

    • Nothing, Git will forget it
    • Delete the .git folder
    • Run git rm --cached secret.txt and commit, and change the secret
    • Run git ignore secret.txt
  15. What does a .gitignore line like *.log do?

    • Deletes log files
    • Tells Git not to track any file ending in .log
    • Commits log files automatically
    • Hides logs from your editor
  16. Which command lists every file Git is tracking?

    • git status
    • git log --files
    • git ls-files
    • git show files
  17. After deleting a file in your file explorer, how do you stage the deletion?

    • You can't
    • git add with the file name, or git add -A
    • git restore
    • git clean
  18. What does .gitattributes with * text=auto eol=lf help with?

    • Ignoring files
    • Making files read-only
    • Keeping line endings consistent between Windows, macOS and Linux
    • Compressing files
  19. Does deleting a committed file with git rm remove it from history?

    • No, earlier commits still contain it
    • Yes
    • Only after pushing
    • Only for large files
  20. What extra does git clean -fdx delete compared with git clean -fd?

    • Tracked files
    • The .git folder
    • Remote branches
    • Ignored files, such as node_modules and .env
  21. Which level of Git setting wins when the same key is set in several places?

    • Local (the repository)
    • System
    • Global
    • The first one set
  22. What does git config --list --show-origin show?

    • Only your aliases
    • The remote repositories
    • Every setting and the file it comes from
    • The commit history
  23. What's the purpose of a Git alias?

    • To rename a branch
    • To hide a commit
    • To share settings with GitHub
    • To create your own shorter name for a Git command
  24. What does --wait do in code --wait as the editor?

    • Makes Git wait until you close the file in VS Code
    • Delays the commit by a minute
    • Opens VS Code in the background
    • Saves automatically
  25. Which file lets a team share line-ending rules inside the repository?

    • .gitignore
    • .gitattributes
    • .gitconfig
    • README.md
  26. Which command switches to an existing branch called main?

    • git branch main
    • git move main
    • git switch main
    • git main
  27. What is HEAD?

    • The first commit
    • A pointer to where you are now, usually the current branch
    • The main branch
    • The newest file
  28. Why is creating a branch so fast in Git?

    • A branch is just a label pointing at a commit; no files are copied
    • Git compresses all files
    • Branches are stored online
    • Git creates branches in the background
  29. Which older command does the same as git switch -c fix-nav?

    • git branch -c fix-nav
    • git new fix-nav
    • git checkout -b fix-nav
    • git checkout fix-nav --create
  30. What is a branch in Git?

    • A copy of the whole project folder
    • A remote server
    • A backup file
    • A movable label pointing at a commit, used for a separate line of work
  31. Into which branch does git merge feature bring changes?

    • feature
    • Always main
    • A new branch
    • The branch you're currently on
  32. What causes a merge conflict?

    • Merging too many files
    • Both branches changing the same lines in different ways
    • Having more than two branches
    • Not having an internet connection
  33. What does the ======= line separate in a conflict?

    • Your current branch's version from the incoming branch's version
    • Two files
    • Old commits from new commits
    • Comments from code
  34. How many parent commits does a merge commit have?

    • None
    • One
    • Two
    • As many as there are files
  35. Which branch should you be on before running git merge feature?

    • feature
    • Any branch
    • The branch that should receive the changes, such as main
    • A new empty branch
  36. When does Git report a conflict?

    • When both branches change the same lines differently
    • Whenever two branches change any file
    • When a branch has more than ten commits
    • When you merge into main
  37. How do you cancel a merge that has conflicts?

    • git reset --merge-cancel
    • git merge --abort
    • Delete the .git folder
    • git stop
  38. What does "both modified" mean in git status?

    • Two people are editing at once
    • Both branches changed this file in ways Git couldn't combine
    • The file was saved twice
    • The file is staged
  39. Which habit prevents most painful conflicts?

    • Never using branches
    • Always using --theirs
    • Committing once a month
    • Keeping branches short-lived and merging main into them often
  40. What does Git's rerere feature do?

    • Reverts merges
    • Renames branches
    • Remembers how you resolved a conflict and reuses that resolution when the same conflict appears again
    • Re-runs tests
  41. Which command discards uncommitted edits to a file?

    • git revert file
    • git restore file
    • git remove file
    • git stash pop file
  42. What does HEAD~1 refer to?

    • The first commit ever
    • The commit before the current one
    • The next commit
    • The main branch
  43. Why is git revert safe for shared history?

    • It adds a new commit instead of changing existing ones
    • It deletes the bad commit everywhere
    • It asks teammates for permission
    • It only works offline
  44. Which command brings back changes saved with git stash?

    • git stash undo
    • git restore --stash
    • git unstash
    • git stash pop
  45. What does git restore --staged file do?

    • Deletes the file
    • Restores the file from GitHub
    • Unstages the file but keeps your edits
    • Commits the file
  46. What does git stash do?

    • Deletes your changes
    • Saves uncommitted changes and cleans the working folder
    • Makes a commit
    • Pushes your changes
  47. Are stashes pushed to GitHub with git push?

    • Yes, always
    • Only named stashes
    • Only with -u
    • No, they stay on your computer
  48. Which command shows the changes inside a stash?

    • git stash list
    • git stash show -p
    • git stash diff
    • git log stash
  49. What happens to a stash when git stash pop hits a conflict?

    • It's kept, so you can drop it yourself after resolving the conflict
    • It's deleted anyway
    • It's pushed to a new branch
    • Git refuses to apply it at all
  50. When is committing to a WIP branch better than stashing?

    • Never
    • When the change is tiny
    • When the work must wait for days or should be backed up remotely
    • When you're on main
  51. Which command lists your remotes and their URLs?

    • git remote list
    • git remote -v
    • git origin
    • git show remotes
  52. What does "diverged" mean?

    • Your branch has been deleted
    • Both your branch and its upstream have commits the other doesn't have
    • You have no remote
    • The branch has conflicts
  53. What does -u do in git push -u origin feature?

    • Updates all branches
    • Undoes the push
    • Sets origin/feature as the upstream of your local feature branch
    • Uploads untracked files
  54. What does git fetch --prune do?

    • Removes remote-tracking branches that no longer exist on the remote
    • Deletes your local branches
    • Shrinks the repository
    • Removes old commits
  55. What does git log main..origin/main show?

    • Your commits that aren't pushed
    • Every commit in the repository
    • Commits on both branches
    • Commits on origin/main that your main doesn't have yet
  56. Which command lists all tags?

    • git tag
    • git tags --all
    • git show tags
    • git log --tags only
  57. What does "detached HEAD" mean?

    • The repository is broken
    • HEAD has been deleted
    • You're on a remote branch
    • You're looking at a specific commit instead of a branch
  58. In semantic versioning, which number changes for a breaking change?

    • MAJOR
    • MINOR
    • PATCH
    • None
  59. How do you tag a commit from the past?

    • You can't
    • git tag --old v0.5
    • git tag -a v0.5 <commit-hash> -m "..."
    • Check it out and wait
  60. What does v1.0.0-3-g52ac9e1 from git describe mean?

    • Version 1.0.3
    • Three commits after the v1.0.0 tag, currently at commit 52ac9e1
    • Three tags called v1.0.0
    • A broken tag
  61. What does rebasing produce compared with merging?

    • More merge commits
    • A deleted branch
    • A linear history without merge commits
    • A new remote
  62. How do you cancel a rebase that's going badly?

    • git rebase --stop
    • git rebase --abort
    • git reset --rebase
    • Delete the .git folder
  63. What does git pull --rebase do?

    • Fetches, then replays your local commits on top of the remote branch
    • Merges the remote with a merge commit
    • Rebases the remote onto your branch
    • Deletes local commits
  64. Which interactive rebase command changes only a commit's message?

    • pick
    • drop
    • squash
    • reword
  65. Why push with --force-with-lease after rebasing your own branch?

    • It's faster than a normal push
    • Normal push is disabled after a rebase
    • The remote has your old commits, and --force-with-lease only overwrites them if nobody else has pushed since
    • It creates a backup branch
  66. Which branch should you be on before cherry-picking?

    • The branch that should receive the commit
    • The branch the commit came from
    • main, always
    • Any branch
  67. How do you continue after resolving a cherry-pick conflict?

    • git commit -m "fix"
    • git merge --continue
    • git cherry-pick --skip
    • git add the files, then git cherry-pick --continue
  68. What does git cherry-pick -n do?

    • Picks the newest commit
    • Applies the changes without committing them
    • Skips conflicts
    • Creates a new branch
  69. What is a backport?

    • Deleting old branches
    • Pushing to a backup server
    • Reverting a commit
    • Copying a fix from a newer branch into an older supported version
  70. Why do small, focused commits make cherry-picking easier?

    • A focused commit contains only the change you want, so it applies cleanly elsewhere
    • Git can only pick small commits
    • Small commits have shorter hashes
    • They don't need messages
  71. Is the reflog pushed to GitHub?

    • No, it only exists in your local repository
    • Yes
    • Only for main
    • Only with --tags
  72. How long do reflog entries last by default?

    • Forever
    • One day
    • About 90 days (30 for commits on no branch) before they can be removed
    • Until you close the terminal
  73. What's the safest way to recover a lost commit without moving your current branch?

    • git reset --hard <hash>
    • git push --force
    • git clean -fd
    • git branch rescued <hash>
  74. What does the reflog record?

    • Only commits
    • Every move of HEAD and branch tips: commits, resets, checkouts, merges and rebases
    • Only pushes
    • Changes in your editor
  75. Why is committing often good insurance?

    • It makes pushes faster
    • Git deletes uncommitted files nightly
    • Only committed work can be recovered through the reflog
    • It reduces repository size
  76. What two pieces of information does bisect need to start?

    • The author's name and email
    • A commit with the bug and an older commit without it
    • The branch name only
    • A remote URL
  77. What does git bisect reset do?

    • Deletes the bad commit
    • Ends the bisect and returns to the branch you started on
    • Restarts the search
    • Resets your files to the bad commit
  78. What does git blame show?

    • Who has access to the repository
    • Failed tests
    • The last commit, author and date that changed each line of a file
    • Deleted branches
  79. What does the -w option do with git blame?

    • Ignores whitespace-only changes
    • Shows warnings
    • Writes the output to a file
    • Shows the whole file history
  80. Why do small commits make bisect more useful?

    • Bisect only works with small commits
    • Small commits are faster to check out
    • They can be skipped automatically
    • The commit bisect finds contains only a few changes, so the bug is easy to spot
  81. Where does Git look for hooks by default?

    • .github/hooks
    • hooks/
    • ~/.gitconfig
    • .git/hooks
  82. Which hook is best for running the full test suite?

    • pre-commit
    • commit-msg
    • pre-push
    • post-checkout
  83. What does git config core.hooksPath .githooks do?

    • Deletes the default hooks
    • Tells Git to run hooks from the committed .githooks folder
    • Copies hooks to GitHub
    • Disables hooks
  84. What is Husky?

    • A tool that installs shared Git hooks in JavaScript projects
    • A Git hosting service
    • A merge tool
    • A type of branch
  85. Can a post-commit hook prevent the commit?

    • No, it runs after the commit already exists
    • Yes, by exiting with 1
    • Only with --no-verify
    • Only on main
  86. Which file records a project's submodules?

    • .gitignore
    • .gitconfig
    • submodules.txt
    • .gitmodules
  87. Which flag clones a project together with its submodules?

    • --all
    • --recurse-submodules
    • --deep
    • --with-modules
  88. Why is a submodule's HEAD often detached?

    • It's broken
    • Submodules can't have branches
    • It's checked out at the exact commit the parent records, not at a branch
    • Because of .gitignore
  89. What does git config --global submodule.recurse true do?

    • Makes pull, switch and checkout update submodules automatically
    • Adds submodules automatically
    • Deletes unused submodules
    • Clones every repository on GitHub
  90. What does mode 160000 in a commit summary mean?

    • An executable file
    • A symbolic link
    • A deleted folder
    • A submodule pointer (a commit reference)
  91. Which command shows all worktrees?

    • git worktree show
    • git branch --worktrees
    • git worktree list
    • git status --all
  92. Does removing a worktree delete its branch?

    • No, the branch stays until you delete it
    • Yes
    • Only if it was merged
    • Only with --force
  93. In git branch output, what does a + next to a branch mean?

    • It's ahead of the remote
    • It has uncommitted changes
    • It's checked out in another worktree
    • It's protected
  94. Where is a good place to create worktree folders?

    • Inside the .git folder
    • Next to the project folder, such as ../shop-hotfix
    • Inside the project folder
    • On the desktop only
  95. What happens if you try to remove a worktree that has untracked files?

    • They're deleted silently
    • They're moved to a stash
    • The branch is deleted
    • Git refuses unless you add --force
  96. What's the first thing to do before starting a new task?

    • Delete old branches
    • Force push
    • Create a tag
    • Switch to main and pull the latest changes
  97. Why keep feature branches short-lived?

    • Git deletes old branches automatically
    • Branches that drift far from main cause large, painful merges
    • Long branches can't be pushed
    • Reviews are only allowed on new branches
  98. What do branch protection rules on GitHub do?

    • Hide the branch
    • Encrypt the branch
    • Prevent cloning
    • Require things like pull requests, reviews and passing tests before merging into a branch
  99. What is a feature flag?

    • A Git tag for features
    • A type of commit message
    • A setting that switches new code on or off without needing a separate branch
    • A branch naming rule
  100. In Git Flow, where must a hotfix be merged?

    • Into main (and tagged) and into develop
    • Only into main
    • Only into develop
    • Into every feature branch
  101. What does MM beside a tracked path describe?

    • Two identical commits already uploaded
    • A file excluded by two ignore patterns
    • Both index-versus-HEAD and working-tree-versus-index modifications
  102. Which command reads the full staged catalog.txt snapshot?

    • git show :catalog.txt
    • git show HEAD:catalog.txt
    • git diff catalog.txt
  103. What changes when HEAD is attached to a branch and you commit?

    • The attached branch advances to the new commit
    • Every tag advances to the new commit
    • The existing parent commit's content is overwritten
  104. Which notation chooses the second parent of a merge commit?

    • HEAD~2
    • HEAD^2
    • HEAD:2
  105. Which file assigns versioned path rules for text normalization?

    • .gitignore
    • .gitattributes
    • .git/HEAD
  106. What does i/lf with w/crlf report for notes.txt?

    • An index conflict that deleted the working file
    • A file excluded from the next commit
    • LF in the index and CRLF in the working tree
  107. Which committed file records the *.bin LFS tracking rule?

    • .gitignore
    • .git/config
    • .gitattributes
  108. What must a complete recovery plan preserve for LFS assets?

    • Repository history and the required separate LFS objects
    • Only branch names, because they contain every binary byte
    • Only the current pointer file size
  109. Which operation creates a separate signed object without rewriting its target commit?

    • Creating a signed annotated tag
    • Changing the commit's author with amend
    • Rebasing the commit onto a new parent
  110. What does a trusted good signature establish in this lesson?

    • Every reachable commit passed all tests
    • The accepted key signed the exact object being verified
    • The hosting account approved the code review
  111. Which export is intended for importing author metadata and commit messages with git am?

    • git status --short
    • git format-patch
    • git diff --stat
  112. What does git apply --check establish?

    • The proposed program passes its test suite
    • The sender's identity has been cryptographically verified
    • The selected application mode can apply the patch to the current state
  113. Which option addresses initial object transfer rather than only working-tree selection?

    • git sparse-checkout list
    • git status --short
    • A server-supported partial-clone filter
  114. What can happen when a partial clone needs a missing historical blob?

    • Git may fetch it from the promisor remote
    • The blob is reconstructed from its filename alone
    • The branch is automatically deleted
  115. Which information should a reliable offline handoff record include?

    • Selected references, expected identifiers and prerequisite history
    • Only the bundle filename
    • Only the developer's editor theme
  116. What does a successful Git bundle restore still leave you checking separately?

    • Whether Git has any commits at all
    • External assets such as LFS content and submodule repositories
    • Whether the bundle can contain named references
  117. What should happen before accepting a remembered conflict resolution?

    • Assume the older decision is always valid
    • Review its current meaning and run relevant checks
    • Delete the branch containing the other side
  118. When is enabling rerere most useful for recording a new resolution?

    • Only after deleting the repository
    • Only after every historical conflict is complete
    • Before encountering and resolving the conflict
  119. In a fetch refspec, what does refs/remotes/origin/main name?

    • The remote server's working directory
    • The local branch currently checked out
    • The local destination for the observed remote branch
  120. Which response best preserves the two contributions in the fixture?

    • Fetch, merge the compatible changes and push normally
    • Replace the remote using unconditional force
    • Delete Bob's local repository immediately
RelaxedNo clock. Read the explanation after each answer.
Timed30 seconds per question. Great for revision.
Exam modeNo feedback until the end, then a full review.

About the Git quiz

This Git quiz checks the ideas from every lesson in the course, from your first git commit to rebasing, the reflog and team workflows. Many questions describe a situation, such as "you committed to the wrong branch" or "your last three commits vanished after a reset", and ask which command fixes it. That's how Git knowledge is tested in real life: not by reciting commands, but by knowing which one to reach for when something goes wrong.

If you've just started, choose Easy and pick a beginner topic like commits or history. After the intermediate lessons, try Mixed with 10 questions, which puts branches, merging, undoing and remotes side by side. Use Exam mode once you've finished the advanced stage; it hides the answers until the end, so it gives an honest picture of what you remember.

When you miss a question, read the explanation and revisit the linked lesson. Pay special attention to the difference between commands that look similar, such as restore and reset, fetch and pull, or merge and rebase. Most Git confusion comes from mixing those pairs up, and a quiz is a safe place to sort them out before it matters.

The question bank holds 120 questions drawn from 30 Git lessons: 21 easy, 80 medium and 19 hard. Every time you start, the quiz picks a fresh random selection that matches your settings, so retaking it is a good way to practise. After each answer, or at the end in exam mode, you'll see why the right answer is right, and every question you miss links back to the lesson that teaches it.

What the Git quiz covers