Sample questions
Question 1Easy
- Linear list of files
- Directed acyclic graph of commits
- Single big file
- Table of diffs only
Answer: B. Directed acyclic graph of commits
Explanation
Each commit points to its parents, so history forms a DAG.
Step-by-step solution
- Each commit points to its parents, so history forms a DAG.
- So the answer is: Directed acyclic graph of commits.
Why the other options are wrong
- A. Branches and merges make it a graph.
- C. Objects are in a database.
- D. Git stores snapshots.
Question 2Easy
Where does Git store repository history on disk?
- In a file named history.txt kept at the top of the project folder
- In the system registry
- In the node_modules folder
- In the hidden .git directory
Answer: D. In the hidden .git directory
Explanation
The .git folder holds objects, refs, config and the index. Deleting it removes the repository.
Step-by-step solution
- Every repo has
.git. - It contains objects and refs.
- Deleting it loses history.
Why the other options are wrong
- A. No such file.
- B. Git does not use a registry.
- C. Unrelated to Git.
Question 3Medium
- HEAD points directly to a commit, not a branch
- The repository is corrupted
- The remote is missing
- HEAD is deleted
Answer: A. HEAD points directly to a commit, not a branch
Explanation
Commits made in this state can be lost unless a branch is created.
Step-by-step solution
- Commits made in this state can be lost unless a branch is created.
- So the answer is: HEAD points directly to a commit, not a branch.
Why the other options are wrong
- B. The repository is fine.
- C. Remotes are unrelated.
- D. HEAD still exists.
Question 4Medium
- Deletes the working files
- Moves the branch back but keeps changes staged
- Keeps changes unstaged
- Rebases the branch
Answer: B. Moves the branch back but keeps changes staged
Explanation
--soft moves only the branch pointer.
Step-by-step solution
- --soft moves only the branch pointer.
- So the answer is: Moves the branch back but keeps changes staged.
Why the other options are wrong
- A. Files are kept.
- C. Unstaged is --mixed.
- D. It does not rebase.
Question 5Medium
Two files in a repo have exactly the same content. How many blob objects does Git store for them?
- Two
- Zero
- One
- Three
Answer: C. One
Explanation
Blobs are named by a hash of content, so identical content is stored once.
Step-by-step solution
- Hash of content is the id.
- Same content gives same id.
- Names live in tree objects.
Why the other options are wrong
- A. That would duplicate content.
- B. Content must be stored.
- D. No extra copy.
Question 6Medium
In which sub-directory is an object with the id ab12cd... stored?
.git/refs/ab12cd.git/ab12cd/.git/hooks/ab.git/objects/ab/ as the file 12cd...
Answer: D. .git/objects/ab/ as the file 12cd...
Explanation
Loose objects use the first two hex characters as a directory and the remainder as the filename.
Step-by-step solution
- Take the id.
- First two chars: folder.
- Rest: file name.
Why the other options are wrong
- A. Refs hold branch pointers.
- B. No such layout.
- C. Hooks hold scripts.
Question 7Medium
The staging area is also called the
- Stash
- Index
- Reflog
- Worktree
Answer: B. Index
Explanation
The index holds the snapshot that the next commit will record.
Step-by-step solution
- The index holds the snapshot that the next commit will record.
- So the answer is: Index.
Why the other options are wrong
- A. The stash stores shelved changes.
- C. The reflog logs ref updates.
- D. The worktree is the working directory.
Question 8Medium
- The commit message
- A directory listing
- A branch name
- The contents of a file, without its name
Answer: D. The contents of a file, without its name
Explanation
File names live in trees. A blob is just the content.
Step-by-step solution
- File names live in trees.
- A blob is just the content.
- So the answer is: The contents of a file, without its name.
Why the other options are wrong
- A. That is the commit.
- B. That is the tree.
- C. That is a ref.
Question 9Hard
A fast-forward merge happens when
- Both branches have new commits
- There are conflicts
- The remote is ahead only
- The target branch has no new commits, so its pointer just moves forward
Answer: D. The target branch has no new commits, so its pointer just moves forward
Explanation
No new merge commit is needed when the history is linear.
Step-by-step solution
- No new merge commit is needed when the history is linear.
- So the answer is: The target branch has no new commits, so its pointer just moves forward.
Why the other options are wrong
- A. That needs a merge commit.
- B. Conflicts prevent fast-forward.
- C. Remote is not required.
Question 10Hard
An annotated tag differs from a lightweight tag in that it
- Is just a branch
- Is a full object with tagger, date and message
- Cannot be pushed
- Is a copy of the repository
Answer: B. Is a full object with tagger, date and message
Explanation
Annotated tags store extra metadata; lightweight tags are plain refs.
Step-by-step solution
- Annotated tags store extra metadata;
- lightweight tags are plain refs.
- So the answer is: Is a full object with tagger, date and message.
Why the other options are wrong
- A. Branches are separate.
- C. Tags can be pushed.
- D. It is not a copy.
Practise all 34 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →