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.
What kind of tool is Git?
- A version control system
- A code editor
- A programming language
- A web browser
What is a repository?
- A Git command
- A website
- A project folder that Git is tracking
- A single file
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
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
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
What does
git initdo?- Downloads a repository
- Makes the first commit
- Installs Git
- Creates a new repository in the current folder
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
What does
-mdo ingit commit -m "Fix typo"?- Gives the commit message on the command line
- Merges the commit
- Commits to the main branch
- Commits only modified files
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
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
Which key quits the
git logview?- Q
- Esc
- Enter
- X
What does
git show 3f9c2abdisplay?- The files in the folder
- The details and changes of that one commit
- Every commit after it
- The branch it's on
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
You committed
secret.txtand 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
What does a .gitignore line like
*.logdo?- Deletes log files
- Tells Git not to track any file ending in .log
- Commits log files automatically
- Hides logs from your editor
Which command lists every file Git is tracking?
- git status
- git log --files
- git ls-files
- git show files
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
What does
.gitattributeswith* text=auto eol=lfhelp with?- Ignoring files
- Making files read-only
- Keeping line endings consistent between Windows, macOS and Linux
- Compressing files
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
What extra does
git clean -fdxdelete compared withgit clean -fd?- Tracked files
- The .git folder
- Remote branches
- Ignored files, such as node_modules and .env
Which level of Git setting wins when the same key is set in several places?
- Local (the repository)
- System
- Global
- The first one set
What does
git config --list --show-originshow?- Only your aliases
- The remote repositories
- Every setting and the file it comes from
- The commit history
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
What does
--waitdo incode --waitas 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
Which file lets a team share line-ending rules inside the repository?
- .gitignore
- .gitattributes
- .gitconfig
- README.md
Which command switches to an existing branch called
main?- git branch main
- git move main
- git switch main
- git main
What is HEAD?
- The first commit
- A pointer to where you are now, usually the current branch
- The main branch
- The newest file
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
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
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
Into which branch does
git merge featurebring changes?- feature
- Always main
- A new branch
- The branch you're currently on
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
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
How many parent commits does a merge commit have?
- None
- One
- Two
- As many as there are files
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
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
How do you cancel a merge that has conflicts?
- git reset --merge-cancel
- git merge --abort
- Delete the .git folder
- git stop
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
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
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
Which command discards uncommitted edits to a file?
- git revert file
- git restore file
- git remove file
- git stash pop file
What does
HEAD~1refer to?- The first commit ever
- The commit before the current one
- The next commit
- The main branch
Why is
git revertsafe 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
Which command brings back changes saved with git stash?
- git stash undo
- git restore --stash
- git unstash
- git stash pop
What does
git restore --staged filedo?- Deletes the file
- Restores the file from GitHub
- Unstages the file but keeps your edits
- Commits the file
What does git stash do?
- Deletes your changes
- Saves uncommitted changes and cleans the working folder
- Makes a commit
- Pushes your changes
Are stashes pushed to GitHub with git push?
- Yes, always
- Only named stashes
- Only with -u
- No, they stay on your computer
Which command shows the changes inside a stash?
- git stash list
- git stash show -p
- git stash diff
- git log stash
What happens to a stash when
git stash pophits 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
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
Which command lists your remotes and their URLs?
- git remote list
- git remote -v
- git origin
- git show remotes
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
What does
-udo ingit push -u origin feature?- Updates all branches
- Undoes the push
- Sets origin/feature as the upstream of your local feature branch
- Uploads untracked files
What does
git fetch --prunedo?- Removes remote-tracking branches that no longer exist on the remote
- Deletes your local branches
- Shrinks the repository
- Removes old commits
What does
git log main..origin/mainshow?- 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
Which command lists all tags?
- git tag
- git tags --all
- git show tags
- git log --tags only
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
In semantic versioning, which number changes for a breaking change?
- MAJOR
- MINOR
- PATCH
- None
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
What does
v1.0.0-3-g52ac9e1from 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
What does rebasing produce compared with merging?
- More merge commits
- A deleted branch
- A linear history without merge commits
- A new remote
How do you cancel a rebase that's going badly?
- git rebase --stop
- git rebase --abort
- git reset --rebase
- Delete the .git folder
What does
git pull --rebasedo?- 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
Which interactive rebase command changes only a commit's message?
- pick
- drop
- squash
- reword
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
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
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
What does
git cherry-pick -ndo?- Picks the newest commit
- Applies the changes without committing them
- Skips conflicts
- Creates a new branch
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
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
Is the reflog pushed to GitHub?
- No, it only exists in your local repository
- Yes
- Only for main
- Only with --tags
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
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>
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
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
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
What does
git bisect resetdo?- 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
What does
git blameshow?- Who has access to the repository
- Failed tests
- The last commit, author and date that changed each line of a file
- Deleted branches
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
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
Where does Git look for hooks by default?
- .github/hooks
- hooks/
- ~/.gitconfig
- .git/hooks
Which hook is best for running the full test suite?
- pre-commit
- commit-msg
- pre-push
- post-checkout
What does
git config core.hooksPath .githooksdo?- Deletes the default hooks
- Tells Git to run hooks from the committed .githooks folder
- Copies hooks to GitHub
- Disables hooks
What is Husky?
- A tool that installs shared Git hooks in JavaScript projects
- A Git hosting service
- A merge tool
- A type of branch
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
Which file records a project's submodules?
- .gitignore
- .gitconfig
- submodules.txt
- .gitmodules
Which flag clones a project together with its submodules?
- --all
- --recurse-submodules
- --deep
- --with-modules
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
What does
git config --global submodule.recurse truedo?- Makes pull, switch and checkout update submodules automatically
- Adds submodules automatically
- Deletes unused submodules
- Clones every repository on GitHub
What does mode 160000 in a commit summary mean?
- An executable file
- A symbolic link
- A deleted folder
- A submodule pointer (a commit reference)
Which command shows all worktrees?
- git worktree show
- git branch --worktrees
- git worktree list
- git status --all
Does removing a worktree delete its branch?
- No, the branch stays until you delete it
- Yes
- Only if it was merged
- Only with --force
In
git branchoutput, 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
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
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
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
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
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
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
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
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
Which command reads the full staged catalog.txt snapshot?
- git show :catalog.txt
- git show HEAD:catalog.txt
- git diff catalog.txt
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
Which notation chooses the second parent of a merge commit?
- HEAD~2
- HEAD^2
- HEAD:2
Which file assigns versioned path rules for text normalization?
- .gitignore
- .gitattributes
- .git/HEAD
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
Which committed file records the *.bin LFS tracking rule?
- .gitignore
- .git/config
- .gitattributes
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
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
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
Which export is intended for importing author metadata and commit messages with git am?
- git status --short
- git format-patch
- git diff --stat
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
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
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
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
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
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
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
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
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
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.