Heads up: opening this section reveals every question, every option, and the correct answer for this round. If you came here to play, scroll up and hit Play first.
Question 1: What is the primary purpose of the 'git init' command?
- To clone a remote repository
- To rename the main branch
- To initialize a new Git repository
- To delete a repository
Answer: C. To initialize a new Git repository
Explanation: The 'git init' command is used to initialize an empty Git repository in the root folder of a project, enabling Git to track changes.
Question 2: Which command moves files from the working directory to the staging area?
- git push
- git pull
- git add
- git commit
Answer: C. git add
Explanation: The 'git add' command is specifically used to stage changes, preparing them to be included in the next commit snapshot.
Question 3: What is the purpose of the 'git commit' command?
- To download files from a remote repository
- To permanently store a snapshot of staged files
- To create a new branch
- To upload files to a server
Answer: B. To permanently store a snapshot of staged files
Explanation: The 'git commit' command takes files from the staging area and saves them as a permanent snapshot in the local Git directory.
Question 4: What is the default name for the primary branch in modern Git repositories?
- root
- master
- base
- main
Answer: D. main
Explanation: While 'master' was historically used, 'main' is now the standard default branch name for new Git repositories in most configurations.
Question 5: Which command transfers committed files to a remote repository?
- git push
- git merge
- git pull
- git fetch
Answer: A. git push
Explanation: The 'git push' command is used to transfer committed files from your local repository to a remote one, making them visible to others.
Question 6: What are Git branches primarily used for?
- Working on features or fixes in isolation
- Managing user permissions
- Deleting old project files
- Compressing the repository size
Answer: A. Working on features or fixes in isolation
Explanation: Branches allow developers to work on different features, bug fixes, or experiments without affecting the stability of the main codebase.
Question 7: Which command retrieves files from a remote repository into the working directory?
- git add
- git commit
- git push
- git pull
Answer: D. git pull
Explanation: The 'git pull' command retrieves files from a remote repository directly into the working directory, effectively combining fetch and merge.
Question 8: What are the three states of a file in Git?
- Local, remote, and global
- New, old, and deleted
- Open, closed, and archived
- Modified, staged, and committed
Answer: D. Modified, staged, and committed
Explanation: Git files exist in three states: modified (changed but not committed), staged (marked for the next commit), and committed (stored in the database).
Question 9: How does Git ensure file integrity?
- By requiring a password for every change
- By storing snapshots as checksummed references
- By encrypting all files
- By limiting file size
Answer: B. By storing snapshots as checksummed references
Explanation: Git stores every committed snapshot as a checksummed reference, making it impossible to change file contents without Git detecting the modification.
Question 10: What is the general behavior of most Git operations?
- They only add data to the database
- They overwrite existing data
- They delete old history
- They compress all files
Answer: A. They only add data to the database
Explanation: Nearly all operations in Git, including adding and committing, only add data to the Git database rather than modifying existing data.