🔧

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.

100 Questions 40 Beginner 40 Intermediate 20 Advanced
1

What is Git?

2

What does the "git init" command do?

3

What is a "repository" (repo) in Git?

4

What does the "git clone" command do?

5

What is the purpose of "git add"?

6

What does "git commit" do?

7

What is the "working directory" in Git?

8

What is the "staging area" (also called the "index") in Git?

9

What does the "git status" command show?

10

What does "git log" display?

11

What is a "branch" in Git?

12

What is the default branch name commonly used in new Git repositories today?

13

What command creates a new branch named "feature-x"?

14

What does "git checkout <branch>" (or "git switch <branch>") do?

15

What is "HEAD" in Git?

16

What does "git pull" do?

17

What does "git push" do?

18

What is a "remote" in Git, e.g. "origin"?

19

What is the purpose of a ".gitignore" file?

20

What is a "merge conflict"?

21

What does "git merge" do?

22

What is the difference between "git fetch" and "git pull"?

23

What is a "commit hash" (or SHA)?

24

What does the "git diff" command show?

25

What is the purpose of "git rm"?

26

What does "git config" allow you to do?

27

What is the difference between "git config --global" and "git config" (local)?

28

What is GitHub (or GitLab/Bitbucket) in relation to Git?

29

What is a "pull request" (PR) or "merge request" (MR)?

30

What does "git revert <commit>" do?

31

What is the purpose of "git tag"?

32

What is the meaning of "untracked" files in "git status" output?

33

What is the purpose of the "README" file commonly found in repositories?

34

What does "git branch" (with no arguments) display?

35

What is the purpose of "git show <commit>"?

36

What is the purpose of "git clone --depth 1"?

37

What is the typical first step before making changes to a shared project hosted on GitHub that you don't have write access to?

38

What does the "git mv" command do?

39

What is the purpose of the "-m" flag in "git commit -m 'message'"?

40

What does it mean when "git status" reports a file as "modified"?

1

What is the difference between "git merge" and "git rebase" when integrating changes from one branch into another?

2

What does "git stash" do?

3

What is the purpose of "git cherry-pick <commit>"?

4

What is the difference between "git reset --soft", "git reset --mixed" (default), and "git reset --hard"?

5

What is a "detached HEAD" state in Git?

6

What is the purpose of "git blame <file>"?

7

What is the difference between a "fast-forward merge" and a "three-way merge"?

8

What does "git rebase -i" (interactive rebase) allow you to do?

9

What does "squashing" commits mean in the context of Git?

10

What is the purpose of "git remote -v"?

11

What is a "fork" vs. a "clone" on a platform like GitHub?

12

What is the purpose of "upstream" tracking branches, e.g. when you see "Your branch is up to date with 'origin/main'"?

13

What is the purpose of "git log --graph --oneline --all"?

14

What is the difference between annotated tags and lightweight tags in Git?

15

What does the ".git" directory contain?

16

What is the purpose of "git reflog"?

17

What is the purpose of "git bisect"?

18

What does "git push --force" (or "-f") do, and why is it considered risky?

19

What is a "merge strategy" like "ours" or "recursive" used for in Git?

20

What is the purpose of "git submodule"?

21

What is the difference between "origin/main" and "main" as seen in "git branch -a" output?

22

What does "git commit --amend" do?

23

What is the purpose of "git clean"?

24

What is the significance of the "Conventional Commits" specification (e.g. "feat:", "fix:", "chore:" prefixes)?

25

What does "git log --follow <file>" do that plain "git log <file>" might not?

26

What is the purpose of a "pre-commit hook" in Git?

27

What happens when you run "git checkout -- <file>" (or "git restore <file>")?

28

What is the purpose of "git diff --staged" (or "--cached")?

29

What does it mean for a Git branch to have "diverged" from its remote tracking branch?

30

What is the purpose of "git worktree"?

31

What is the difference between "git fetch --all" and "git fetch origin"?

32

What is the significance of "merge commits" having two (or more) "parent" commits?

33

What is the purpose of using "SSH keys" for authenticating with GitHub instead of HTTPS with a password?

34

What is the purpose of "git diff branch1...branch2" (three dots) versus "git diff branch1..branch2" (two dots)?

35

What is the purpose of "git stash branch <branchname>"?

36

What is the difference between "git branch -d" and "git branch -D"?

37

What does "git log --since='2 weeks ago' --author='Jane'" do?

38

What is the purpose of "git add -p" (patch mode)?

39

What is the significance of a "protected branch" on platforms like GitHub?

40

What does the term "CI/CD" mean in the context of a Git-based workflow, and how do platforms typically trigger it?

1

How does Git internally store the content of files and directories — what are "blobs", "trees", and "commits"?

2

What is the difference between Git's "object database" and the "index" (staging area) at a low level?

3

What is "git gc" (garbage collection), and why might "loose objects" accumulate in a repository?

4

How does Git determine whether a file has been "renamed" between two commits, given that it doesn't explicitly store rename operations?

5

What is the difference between "git merge --squash" and a regular "git merge" followed by squashing via interactive rebase?

6

What is "the three-way merge algorithm" and what role does the "merge base" (common ancestor) play in it?

7

What is "git filter-branch" (or the more modern "git filter-repo") used for, and why is it considered dangerous on shared repositories?

8

What is the purpose of Git's "packed-refs" file, and how does it relate to loose refs in ".git/refs/"?

9

What does it mean for Git to use "content-addressable storage", and what guarantee does this provide?

10

What is the difference between "git rebase" and "git rebase --onto"?

11

How do Git "hooks" differ between client-side and server-side, and what is a common server-side use case for "pre-receive" hooks?

12

What is "git worktree prune" and when might dangling worktree references occur?

13

How 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?

14

What is a "shallow clone" limitation when it comes to operations like "git push" or fetching specific history later?

15

In a Git repository with submodules, what does it mean that the parent repository tracks a specific "commit" of the submodule rather than a "branch"?

16

What is "git's ORIG_HEAD" reference, and when is it typically set?

17

What is the difference between "git merge-base" and simply looking at the parent of the current commit?

18

Why 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?

19

What is the purpose of Git's "sparse-checkout" feature, and what problem does it solve for very large repositories (monorepos)?

20

What does it mean that Git branches are "cheap" compared to branching in some older version control systems (like Subversion)?