---
title: "Git: Version Control Fundamentals"
description: "Test your knowledge of Git fundamentals with this comprehensive quiz covering commits, branches, merging, rebasing, remote repositories, staging, conflict resolution, and version control best practices."
author: "Mohammad Abu Mattar"
canonical: https://mkabumattar.com/quizzes/post/git-version-control-fundamentals-quiz
---

# Git: Version Control Fundamentals

Welcome to the Git Basics Quiz! This quiz is designed to test your understanding of fundamental Git concepts, version control workflows, and collaborative development best practices. Each question is multiple-choice, and you'll find hints to help you along the way. Good luck!

## Questions

### 1. What is the command to initialize a new Git repository in an existing directory?

- `git start`
  - This is not a standard Git command; initialization requires the "init" subcommand.
- **`git init`** ✅
  - The init command creates the .git subdirectory and the skeletal structure for a new repository.
- `git setup`
  - While "setup" is a common task, it is not a native command for creating a repository.
- `git create`
  - Native Git uses "init" for local creation; "create" is often a flag in external CLI tools.

**Hint:** Think "Initialize".

### 2. What is the "Staging Area" (Index) in Git?

- A remote server backup
  - Staging is a local operation that occurs before any data is sent to a remote server.
- **A buffer for pending commits** ✅
  - The index serves as a middle ground where changes are gathered before being snapshotted.
- A log of all deleted items
  - While it tracks deletions, the index is a snapshot of the next intended commit, not just a log.
- A permanent project history
  - The permanent history is stored in the Object Database; the staging area is purely transitional.

**Hint:** It is the middle ground between your files and a commit.

### 3. How do you move changes from the Working Directory to the Staging Area?

- `git save <file>`
  - Git does not use "save"; it requires explicit staging with "add" before committing.
- **`git add <file>`** ✅
  - The add command updates the index using the current content found in the working tree.
- `git stage <file>`
  - While "stage" is a valid alias in some Git versions, "add" is the primary command for this action.
- `git push <file>`
  - The push command interacts with remotes and cannot be used to move local files to the index.

**Hint:** Think "Add".

### 4. What is the purpose of "git commit"?

- To download remote files
  - Downloading remote content is handled by "fetch" or "pull", not by the commit command.
- **To snapshot staged changes** ✅
  - Committing creates a permanent record of the staging area as a new node in the commit graph.
- To discard unmerged work
  - Discarding changes is typically handled by "reset" or "checkout", while commit preserves them.
- To rebase a local branch
  - Rebasing is a distinct workflow for rewriting history; "commit" only adds new history.

**Hint:** It takes a snapshot.

### 5. What does "git status" show?

- A list of project authors
  - Author information is retrieved via "log" or "shortlog" rather than the status command.
- **The state of tracked files** ✅
  - The status command displays the differences between the index and the current HEAD commit.
- The network latency speed
  - Status is a local metadata check and does not involve network diagnostics or performance.
- A log of historical commits
  - Historical records are managed by the "log" command; "status" only shows the current state.

**Hint:** Checking the current state.

### 6. How do you create a new branch and switch to it immediately?

- `git branch <name>`
  - This command creates a new branch pointer but does not move the HEAD to that new branch.
- **`git checkout -b <name>`** ✅
  - The "-b" flag combines the branch creation and checkout operations into a single step.
- `git switch <name>`
  - Switching only works for existing branches unless the "-c" flag is explicitly provided.
- `git move -b <name>`
  - There is no "move" command for branch creation; Git uses branch, checkout, or switch.

**Hint:** A shortcut for checkout.

### 7. What is "git clone" used for?

- To remove a local repository
  - Cloning creates data; removal is handled by file system commands like "rm -rf".
- **To copy a remote repository** ✅
  - Cloning creates a local version of a remote repo, including all history and branch references.
- To merge divergent branches
  - Merging is a local integration task handled by the "merge" command, not by cloning.
- To update user configuration
  - User settings like email or name are managed by "git config", not by cloning repos.

**Hint:** Copying a project.

### 8. What is a "Merge Conflict"?

- A disk space overflow error
  - Conflicts are logical data discrepancies, not hardware-level storage limitations.
- **A failure in automatic merging** ✅
  - Conflicts occur when Git cannot resolve differences between two commits on the same line of code.
- A network authentication fail
  - Authentication failures relate to security permissions, whereas conflicts relate to file content.
- An empty commit message error
  - Missing messages prevent a commit from completing but do not constitute a merge conflict.

**Hint:** Two people changed the same line.

### 9. What does "git pull" do?

- Uploads local commits
  - Uploading is the role of "push"; "pull" is used for downloading and integrating.
- **Fetches and merges data** ✅
  - Pull is a convenience command that runs "git fetch" followed by a "git merge" automatically.
- Resets the working tree
  - Pulling aims to integrate new data; resetting is used to revert to a previous state.
- Compares two local files
  - File comparison is handled by "diff"; "pull" handles network synchronization.

**Hint:** Fetch + Merge.

### 10. What is "The SHA" (Hash) in Git?

- The repository owner name
  - Owner information is part of the commit metadata (Author/Committer), not the hash itself.
- **A commit unique identifier** ✅
  - A SHA-1 hash is a 40-character string that uniquely identifies the content and history of a commit.
- The access token for SSH
  - SSH tokens are for secure communication; hashes are for data integrity and identification.
- A command to prune history
  - Pruning is handled by "gc" or "prune"; SHA is a data value, not a functional command.

**Hint:** The unique ID for a commit.

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

- To encrypt sensitive data
  - Ignore files only prevent tracking; they do not provide encryption or security for files.
- **To exclude untracked files** ✅
  - A .gitignore file tells Git which files should remain untracked and ignored by the "add" command.
- To purge files from remotes
  - Ignore files prevent future tracking but do not remove files that are already in the repository history.
- To optimize the commit speed
  - The primary purpose is cleanliness and avoiding junk files, rather than direct performance optimization.

**Hint:** Telling Git what NOT to track.

### 12. What does "git log" do?

- Monitors real-time changes
  - Real-time monitoring is not a Git function; "log" is used for historical inspection.
- **Lists the commit history** ✅
  - The log command displays the sequence of commits made to the current branch in reverse-chronological order.
- Initializes the repository
  - Initialization is handled by "init"; "log" requires an existing history to function.
- Authenticates remote users
  - Authentication is handled by SSH or HTTPS protocols, not by the history log.

**Hint:** The history book.

### 13. What is "git merge"?

- A method for branch removal
  - Branch deletion is a metadata cleanup task handled by "git branch -d".
- **Integrating separate histories** ✅
  - Merge combines the changes from one branch (the source) into another (the target).
- A method for file renaming
  - Renaming is a file system change handled by "git mv" to maintain tracking.
- Hosting code on a website
  - Hosting is provided by services like GitHub; Git itself is the version control engine.

**Hint:** Combining branches.

### 14. What is the "HEAD" in Git?

- The initial root commit
  - The root commit is the starting point of history; HEAD is the current active point.
- **A pointer to the active branch** ✅
  - HEAD is a symbolic reference to the branch or commit currently checked out in the working directory.
- The top-level project directory
  - The directory is the "Working Tree"; HEAD is an internal Git reference pointer.
- The primary remote repository
  - Remotes are external locations; HEAD is a local reference within the .git directory.

**Hint:** You are here.

### 15. What does "git push" do?

- Clears the local commit log
  - Pushing preserves local history and merely duplicates it onto a remote server.
- **Sends local commits to remote** ✅
  - The push command updates remote refs using local objects and associated history.
- Fetches new remote updates
  - Updating local data from a remote is handled by "fetch" or "pull", not "push".
- Resolves local merge conflicts
  - Conflicts must be resolved locally before a push can be successfully completed.

**Hint:** Sending data away.

### 16. What is "git diff"?

- A tool for binary conversion
  - Diff is designed for comparing text-based differences in source code files.
- **Comparing tree and index** ✅
  - The diff command shows the changes between the working directory, the index, and the HEAD.
- A tool for file system cleanup
  - Cleanup and pruning are handled by "clean" or "gc", not by comparison tools.
- A way to jump between branches
  - Navigation between branches is the role of "checkout" or "switch".

**Hint:** Looking for differences.

### 17. What is a "Remote" in Git?

- An external hardware drive
  - While a remote can be on an external drive, in Git it specifically refers to a repository URL.
- **A shared project repository** ✅
  - A remote is a common version of the project hosted on a network or server for collaboration.
- A developer on another team
  - In version control, "remote" refers to a data location, not a human participant.
- A configuration file in .git
  - Configuration is stored in "config," which contains pointers to remote locations.

**Hint:** The version of the project on the internet.

### 18. What is the "Main" (or "Master") branch?

- A temporary feature branch
  - Feature branches are short-lived; Main is intended to be the permanent history.
- **The stable production branch** ✅
  - The Main branch typically serves as the primary source of truth for stable, deployable code.
- A read-only archive branch
  - The main branch is usually active and updated, though it may have protection rules.
- A branch for user permissions
  - Permissions are handled by the hosting platform, not by branch structures.

**Hint:** The default line of development.

### 19. What is "git stash"?

- A permanent deletion command
  - Stashing is a temporary storage mechanism; it does not delete or purge history.
- **Storing uncommitted work** ✅
  - Stash saves the current state of the working directory and index to a stack for later use.
- An encrypted security vault
  - The stash is an internal Git stack and does not provide encryption or secure storage.
- A directory for static assets
  - Assets are stored in the working directory; the stash is an internal Git data structure.

**Hint:** Temporarily putting changes aside.

### 20. What is a "Fast-forward" merge?

- A high-speed network upload
  - This refers to the movement of branch pointers, not the speed of data transmission.
- **A linear branch pointer update** ✅
  - Fast-forwarding occurs when the target branch has not diverged from the source branch.
- An automated error resolution
  - Fast-forwarding only happens in clean, linear histories and does not resolve errors.
- A way to revert several commits
  - Reverting is a separate operation; fast-forwarding is an integration strategy.

**Hint:** No new merge commit is needed.

### 21. What does "git fetch" do?

- **Downloads remote metadata** ✅
  - Fetch retrieves objects and refs from another repository without merging them into your local work.
- Integrates changes automatically
  - Automatic integration is the role of "pull"; "fetch" is a non-destructive download.
- Uploads local object data
  - Uploading is performed by the "push" command; "fetch" is purely an inbound operation.
- Removes the remote reference
  - Fetch updates local references to match the remote; it does not remove them.

**Hint:** Download only, no merge.

### 22. How do you undo a commit by creating a NEW commit with opposite changes?

- `git reset --hard`
  - Hard resets overwrite history and are destructive; they do not create a new "undo" commit.
- **`git revert <commit>`** ✅
  - Revert records a new commit that applies inverse changes, preserving the original history.
- `git remove <commit>`
  - There is no "remove" command for commits; Git uses revert or reset for these actions.
- `git rollback <commit>`
  - Rollback is not a native Git command; it is terminology often used in database management.

**Hint:** Safety first.

### 23. What is "git rebase"?

- Changing the project name
  - Renaming projects is an administrative task outside the scope of the rebase command.
- **Reapplying commits on a base** ✅
  - Rebase moves a sequence of commits to a new base commit, resulting in a linear history.
- Backing up the repository
  - Backups are handled by mirroring or pushing; rebasing is a history manipulation tool.
- Deleting obsolete branches
  - Branch deletion is managed by the "branch -d" command, not by rebasing history.

**Hint:** Rewriting history to make it linear.

### 24. What is a "Fork"?

- A critical software vulnerability
  - A fork is a platform feature for collaboration, not a security flaw or software bug.
- **A server-side repository copy** ✅
  - Forking creates a copy of a repository on the server under a different user account.
- A tool for dividing source files
  - Git does not have a "fork" command for splitting files; it manages entire repositories.
- A method for user management
  - User roles are managed in platform settings; forks are copies of the data itself.

**Hint:** A personal copy of someone else's project.

### 25. What is a "Pull Request" (or Merge Request)?

- A request for billing access
  - Billing is an administrative platform concern, not a version control workflow.
- **A proposal for code integration** ✅
  - Pull Requests allow developers to notify team members about completed features for review.
- A command to sync remote data
  - Synchronizing is done via "pull" or "fetch"; a Pull Request is a social/review feature.
- A report for project issues
  - Issues are used for tracking bugs; Pull Requests are used for submitting code changes.

**Hint:** Asking to merge your code.

### 26. What is the "Working Directory"?

- The directory of Git binaries
  - Binaries are stored in system paths; the working directory is specific to your project code.
- **The current checked-out files** ✅
  - The working directory consists of the files on your disk that you are actively modifying.
- The internal .git object store
  - The object store is part of the repository database, not the editable working directory.
- A list of all remote branches
  - Remote branch references are stored in the .git/refs folder, not the working directory.

**Hint:** Where you actually type your code.

### 27. What does "git remote -v" show?

- `The installed Git version`
  - Checking the application version is performed using the "--version" flag.
- **`The fetch and push URLs`** ✅
  - The "-v" flag stands for "verbose" and displays the full URLs for all configured remotes.
- `A list of project developers`
  - Remote settings track data locations, not the individual identities of all contributors.
- `The total count of files`
  - File counts are determined by shell commands or "ls-files," not by remote configurations.

**Hint:** Verbose remote info.

### 28. What happens if you run "git checkout <filename>"?

- `The file is permanently deleted`
  - The file remains; however, its uncommitted changes are discarded and replaced.
- **`The file reverts to HEAD state`** ✅
  - This command overwrites the working tree file with the version currently in the index/HEAD.
- `The file opens in an editor`
  - Git does not launch editors for file checkout; it only modifies the file content on disk.
- `The file is renamed in Git`
  - Renaming is a specific operation performed by the "mv" command, not by checkout.

**Hint:** Discarding local changes.

### 29. What is "git rm"?

- A command to reset the repo
  - Resetting history is handled by "reset"; "rm" is used for file removal and staging.
- **Removing files from the index** ✅
  - The rm command removes files from the working tree and stages the deletion for the next commit.
- A command to read metadata
  - Reading metadata is performed by "log" or "show"; "rm" is an action-oriented command.
- A way to rename a branch
  - Branch renaming is a metadata change handled by "branch -m," not by file removal.

**Hint:** Removing a file.

### 30. What is a "Cherry-pick"?

- Selecting a random contributor
  - Contributor selection is not a technical function of the Git version control system.
- **Applying a specific commit** ✅
  - Cherry-picking introduces the changes from an existing commit into the current HEAD.
- Deleting specific file types
  - Selective deletion is handled by "clean" or "rm," not by the cherry-pick command.
- Identifying the first version
  - Locating the root commit is done via "log" or "rev-list," not by cherry-picking.

**Hint:** Selecting one specific commit.
