Technology Technology · Programming ● Easy

Git Commands quiz

Git becomes easier when you understand the state of your files instead of memorizing commands in isolation. This quiz covers the working tree, staging area, commits, branches, history, diffs, remotes, and safer ways to undo common mistakes. Each question uses a practical command-line situation and explains what the command changes, helping beginners build a mental model they can use in real repositories.

Start the quiz
Questions
10
Time
11 min
Difficulty
● Easy
Git Commands Quiz cover showing a sample quiz question and a branching git add, commit, and push workflow
Technology · Easy
TestYourChoice original artwork
Quick info

Before you start

Best for

Developers learning Git from the command line

Format

10 explanation-backed questions in about 11 minutes.

What you'll cover

A small map of the test

  1. 1Working tree, staging area, and commits
  2. 2Inspecting status and differences
  3. 3Creating and switching branches
  4. 4Viewing history and working with remotes
  5. 5Safer ways to unstage or restore changes
Audience

Who this quiz is for

  • Developers learning Git from the command line
  • Learners who know a few commands but want a clearer workflow model
Key concepts

Ideas this quiz checks

Working tree

The checked-out files you are currently viewing and editing.

Staging area

The index that holds the exact content intended for the next commit.

Commit

A recorded snapshot of the staged project state with metadata and a message.

Branch

A movable name pointing to a commit, used to develop lines of work independently.

Score guide

How to read your score

  1. 0–4 Rebuild the Git model

    Focus on the working tree, staging area, and commit before memorizing more commands.

  2. 5–7 Working command base

    You understand the everyday flow, with a few branch, remote, or restore details to reinforce.

  3. 8–10 Strong Git fundamentals

    You understand the state model and the commands behind a typical local workflow.

After the quiz

Recommended next steps

  • Create a disposable repository and observe status after every command
  • Review both unstaged and staged diffs before committing
  • Use branches for isolated work and inspect incoming remote changes before integration
References

Sources and further reading

How to play

Instructions

  1. You have 11 minutes total to answer 10 multiple-choice questions.
  2. Choose an answer to lock it in. The runner immediately shows the correct answer and explanation.
  3. Use Hint when you want a nudge, or Skip to move forward without answering.
  4. Keyboard shortcuts: A-D answer, H hints, S skips, Enter/ next, and previous.
  5. No signup required. Your progress is local to this quiz session.
Every question, explained

Answer key and explanations

All 10 questions from this quiz, with the correct answer and the reasoning behind it. Take the quiz first if you want an honest score — or read straight through and use this as revision material.

  1. Which command gives a summary of the current branch and modified, staged, and untracked files?

    • git statusCorrect
    • git push
    • git tag
    • git clone

    Why: `git status` reports differences between the working tree, staging area, and current commit, including untracked files by default. It is a safe first command when you need to understand the repository's current state.

  2. What does `git add report.md` do after you edit the file?

    • Uploads the file to a remote
    • Stages the file's current content for the next commitCorrect
    • Creates a new branch
    • Permanently deletes the file

    Why: `git add` copies the selected file's current content into the staging area, also called the index. Later edits to the working-tree file are not automatically included; the file must be added again to stage the newer content.

  3. Before committing, which command shows the exact staged changes that would enter the commit?

    • git diff --cachedCorrect
    • git status --ignored
    • git branch -d
    • git pull

    Why: `git diff --cached`—also available as `git diff --staged`—shows the difference between the staging area and the current commit. Plain `git diff` normally shows unstaged working-tree changes instead.

  4. What does a normal `git commit` record?

    • Every modified file whether staged or not
    • A snapshot of the content currently in the staging areaCorrect
    • Only files already uploaded to a remote
    • The complete internet history of the project

    Why: A normal commit records the snapshot assembled in the staging area. Modified but unstaged content stays in the working tree and is not included, which is why reviewing status and the staged diff before committing is useful.

  5. Which command creates and switches to a new branch named `quiz-copy` in one step?

    • git switch -c quiz-copyCorrect
    • git merge quiz-copy
    • git status quiz-copy
    • git remote add quiz-copy

    Why: `git switch -c quiz-copy` creates the new branch and switches the working tree to it. The older `git checkout -b quiz-copy` form is also common, but `git switch` communicates branch switching more directly.

  6. Which command is primarily used to inspect commit history?

    • git logCorrect
    • git add
    • git init
    • git clean

    Why: `git log` displays commit history and supports options for filtering and formatting it. It is an inspection command: running it does not stage files, create a repository, or remove working-tree content.

  7. You staged `config.js` by mistake but want to keep your working-tree edits. What is the focused modern command?

    • git restore --staged config.jsCorrect
    • git restore config.js
    • git clean -fd
    • git branch -D config.js

    Why: `git restore --staged config.js` removes the path from the staging area while leaving the working-tree edits in place. By contrast, `git restore config.js` without `--staged` can replace working-tree content and may discard uncommitted changes.

  8. What does `git fetch origin` generally do?

    • Downloads updated remote references without automatically merging them into the current branchCorrect
    • Deletes the remote repository
    • Stages every local file
    • Rewrites every local commit

    Why: `git fetch origin` contacts the remote and updates remote-tracking information without automatically integrating those commits into the current branch. That lets you inspect incoming work before choosing how to merge or rebase it.

  9. What is the usual purpose of `git merge feature-report` while you are on another branch?

    • Join the history from `feature-report` into the current branchCorrect
    • Rename the current branch
    • Stage only `report.md`
    • Show ignored files

    Why: `git merge feature-report` integrates the named branch's history into the branch currently checked out. Depending on the histories, Git may fast-forward, create a merge commit, or stop for conflicts that require resolution.

  10. Which statement best describes `git restore notes.md` when the file has unstaged edits?

    • It is always a read-only inspection command
    • It can replace working-tree content and discard those unstaged editsCorrect
    • It uploads the edits to the remote
    • It creates a backup branch automatically

    Why: Restoring a working-tree path can overwrite its unstaged content with another version, so uncommitted edits may be lost. Inspect `git status` and `git diff` first, and preserve work before using commands that intentionally replace files.