Git & Version Control MCQ
Test your Git & Version Control knowledge with 100 multiple choice questions covering fundamentals to advanced concepts, with instant feedback and explanations.
What is Git?
2What does the "git init" command do?
3What is a "repository" (repo) in Git?
4What does the "git clone" command do?
5What is the purpose of "git add"?
6What does "git commit" do?
7What is the "working directory" in Git?
8What is the "staging area" (also called the "index") in Git?
9What does the "git status" command show?
10What does "git log" display?
11What is a "branch" in Git?
12What is the default branch name commonly used in new Git repositories today?
13What command creates a new branch named "feature-x"?
14What does "git checkout <branch>" (or "git switch <branch>") do?
15What is "HEAD" in Git?
16What does "git pull" do?
17What does "git push" do?
18What is a "remote" in Git, e.g. "origin"?
19What is the purpose of a ".gitignore" file?
20What is a "merge conflict"?
21What does "git merge" do?
22What is the difference between "git fetch" and "git pull"?
23What is a "commit hash" (or SHA)?
24What does the "git diff" command show?
25What is the purpose of "git rm"?
26What does "git config" allow you to do?
27What is the difference between "git config --global" and "git config" (local)?
28What is GitHub (or GitLab/Bitbucket) in relation to Git?
29What is a "pull request" (PR) or "merge request" (MR)?
30What does "git revert <commit>" do?
31What is the purpose of "git tag"?
32What is the meaning of "untracked" files in "git status" output?
33What is the purpose of the "README" file commonly found in repositories?
34What does "git branch" (with no arguments) display?
35What is the purpose of "git show <commit>"?
36What is the purpose of "git clone --depth 1"?
37What is the typical first step before making changes to a shared project hosted on GitHub that you don't have write access to?
38What does the "git mv" command do?
39What is the purpose of the "-m" flag in "git commit -m 'message'"?
40What does it mean when "git status" reports a file as "modified"?
What is the difference between "git merge" and "git rebase" when integrating changes from one branch into another?
2What does "git stash" do?
3What is the purpose of "git cherry-pick <commit>"?
4What is the difference between "git reset --soft", "git reset --mixed" (default), and "git reset --hard"?
5What is a "detached HEAD" state in Git?
6What is the purpose of "git blame <file>"?
7What is the difference between a "fast-forward merge" and a "three-way merge"?
8What does "git rebase -i" (interactive rebase) allow you to do?
9What does "squashing" commits mean in the context of Git?
10What is the purpose of "git remote -v"?
11What is a "fork" vs. a "clone" on a platform like GitHub?
12What is the purpose of "upstream" tracking branches, e.g. when you see "Your branch is up to date with 'origin/main'"?
13What is the purpose of "git log --graph --oneline --all"?
14What is the difference between annotated tags and lightweight tags in Git?
15What does the ".git" directory contain?
16What is the purpose of "git reflog"?
17What is the purpose of "git bisect"?
18What does "git push --force" (or "-f") do, and why is it considered risky?
19What is a "merge strategy" like "ours" or "recursive" used for in Git?
20What is the purpose of "git submodule"?
21What is the difference between "origin/main" and "main" as seen in "git branch -a" output?
22What does "git commit --amend" do?
23What is the purpose of "git clean"?
24What is the significance of the "Conventional Commits" specification (e.g. "feat:", "fix:", "chore:" prefixes)?
25What does "git log --follow <file>" do that plain "git log <file>" might not?
26What is the purpose of a "pre-commit hook" in Git?
27What happens when you run "git checkout -- <file>" (or "git restore <file>")?
28What is the purpose of "git diff --staged" (or "--cached")?
29What does it mean for a Git branch to have "diverged" from its remote tracking branch?
30What is the purpose of "git worktree"?
31What is the difference between "git fetch --all" and "git fetch origin"?
32What is the significance of "merge commits" having two (or more) "parent" commits?
33What is the purpose of using "SSH keys" for authenticating with GitHub instead of HTTPS with a password?
34What is the purpose of "git diff branch1...branch2" (three dots) versus "git diff branch1..branch2" (two dots)?
35What is the purpose of "git stash branch <branchname>"?
36What is the difference between "git branch -d" and "git branch -D"?
37What does "git log --since='2 weeks ago' --author='Jane'" do?
38What is the purpose of "git add -p" (patch mode)?
39What is the significance of a "protected branch" on platforms like GitHub?
40What does the term "CI/CD" mean in the context of a Git-based workflow, and how do platforms typically trigger it?
How does Git internally store the content of files and directories — what are "blobs", "trees", and "commits"?
2What is the difference between Git's "object database" and the "index" (staging area) at a low level?
3What is "git gc" (garbage collection), and why might "loose objects" accumulate in a repository?
4How does Git determine whether a file has been "renamed" between two commits, given that it doesn't explicitly store rename operations?
5What is the difference between "git merge --squash" and a regular "git merge" followed by squashing via interactive rebase?
6What is "the three-way merge algorithm" and what role does the "merge base" (common ancestor) play in it?
7What is "git filter-branch" (or the more modern "git filter-repo") used for, and why is it considered dangerous on shared repositories?
8What is the purpose of Git's "packed-refs" file, and how does it relate to loose refs in ".git/refs/"?
9What does it mean for Git to use "content-addressable storage", and what guarantee does this provide?
10What is the difference between "git rebase" and "git rebase --onto"?
11How do Git "hooks" differ between client-side and server-side, and what is a common server-side use case for "pre-receive" hooks?
12What is "git worktree prune" and when might dangling worktree references occur?
13How does "git log" determine commit order when displaying history, and what is the difference between "--topo-order" and the default chronological ordering when branches have merge commits?
14What is a "shallow clone" limitation when it comes to operations like "git push" or fetching specific history later?
15In a Git repository with submodules, what does it mean that the parent repository tracks a specific "commit" of the submodule rather than a "branch"?
16What is "git's ORIG_HEAD" reference, and when is it typically set?
17What is the difference between "git merge-base" and simply looking at the parent of the current commit?
18Why can rewriting a single early commit in a long history (e.g. via interactive rebase to edit a commit from months ago) be considered an expensive and disruptive operation?
19What is the purpose of Git's "sparse-checkout" feature, and what problem does it solve for very large repositories (monorepos)?
20What does it mean that Git branches are "cheap" compared to branching in some older version control systems (like Subversion)?