Git & GitHub Quiz
Git tracks changes in your code and GitHub hosts repositories for collaboration. This quiz covers commits, branches, merging, pull requests, remotes and the commands you use every day.
What this quiz covers
- init, add, commit and status
- Branches and merging
- Remotes, push and pull
- Pull requests and collaboration
Study tip: Create a practice repository and deliberately cause a merge conflict; resolving it once teaches more than reading about it.
Questions, answers and explanations
1. What is Git?
- A Programming Language
- A Version Control System
- A Database
- A Web Browser
Answer: A Version Control System
Git is a distributed version control system used to track changes in source code.
2. Who created Git?
- James Gosling
- Linus Torvalds
- Guido van Rossum
- Dennis Ritchie
Answer: Linus Torvalds
Git was created by Linus Torvalds in 2005.
3. What is GitHub?
- A Database
- A Cloud Platform for Git Repositories
- A Programming Language
- A Web Framework
Answer: A Cloud Platform for Git Repositories
GitHub is an online platform for hosting and collaborating on Git repositories.
4. Which command initializes a new Git repository?
- git init
- git start
- git create
- git new
Answer: git init
The 'git init' command creates a new Git repository.
5. Which command checks the current status of a Git repository?
- git status
- git check
- git info
- git state
Answer: git status
git status displays the state of the working directory and staging area.
6. Which command adds files to the staging area?
- git add
- git push
- git stage
- git commit
Answer: git add
git add stages changes before committing.
7. Which command saves changes permanently to the repository?
- git commit
- git push
- git save
- git upload
Answer: git commit
git commit records staged changes in the repository.
8. Which command uploads local commits to GitHub?
- git push
- git upload
- git publish
- git send
Answer: git push
git push uploads local commits to a remote repository.
9. Which command downloads a GitHub repository to your computer?
- git clone
- git copy
- git download
- git fetch
Answer: git clone
git clone copies a remote repository to your local machine.
10. Which command downloads the latest changes without merging them?
- git fetch
- git pull
- git merge
- git clone
Answer: git fetch
git fetch downloads updates from the remote repository without merging.
11. Which command downloads and merges changes from a remote repository?
- git pull
- git fetch
- git merge
- git clone
Answer: git pull
git pull fetches changes from the remote repository and merges them into the current branch.
12. Which command creates a new branch?
- git branch
- git new
- git checkout
- git create
Answer: git branch
The git branch command creates a new branch.
13. Which command switches to another branch?
- git checkout
- git branch
- git switchbranch
- git move
Answer: git checkout
git checkout <branch-name> switches to another branch.
14. Which command merges one branch into another?
- git merge
- git combine
- git join
- git push
Answer: git merge
git merge combines changes from one branch into another.
15. Which command shows the commit history?
- git log
- git history
- git commits
- git show
Answer: git log
git log displays the commit history of the repository.
16. Which command removes a file from Git tracking?
- git rm
- git remove
- git delete
- git clean
Answer: git rm
git rm removes a file from both the working directory and Git tracking.
17. What is a repository (repo) in Git?
- A folder containing project files and Git history
- A programming language
- A cloud server
- A database
Answer: A folder containing project files and Git history
A repository stores project files and their version history.
18. What is the purpose of branching in Git?
- To work on new features without affecting the main code
- To delete files
- To upload projects
- To install Git
Answer: To work on new features without affecting the main code
Branches allow independent development without changing the main branch.
19. Which GitHub feature is commonly used to request code review before merging?
- Pull Request
- Fork
- Issue
- Release
Answer: Pull Request
A Pull Request allows team members to review code before merging.
20. What is one major advantage of Git and GitHub?
- Version Control
- Team Collaboration
- Backup of Code
- All of the above
Answer: All of the above
Git and GitHub provide version control, collaboration, and secure code backup.