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

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?

  1. A Programming Language
  2. A Version Control System
  3. A Database
  4. 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?

  1. James Gosling
  2. Linus Torvalds
  3. Guido van Rossum
  4. Dennis Ritchie

Answer: Linus Torvalds

Git was created by Linus Torvalds in 2005.

3. What is GitHub?

  1. A Database
  2. A Cloud Platform for Git Repositories
  3. A Programming Language
  4. 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?

  1. git init
  2. git start
  3. git create
  4. 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?

  1. git status
  2. git check
  3. git info
  4. 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?

  1. git add
  2. git push
  3. git stage
  4. git commit

Answer: git add

git add stages changes before committing.

7. Which command saves changes permanently to the repository?

  1. git commit
  2. git push
  3. git save
  4. git upload

Answer: git commit

git commit records staged changes in the repository.

8. Which command uploads local commits to GitHub?

  1. git push
  2. git upload
  3. git publish
  4. git send

Answer: git push

git push uploads local commits to a remote repository.

9. Which command downloads a GitHub repository to your computer?

  1. git clone
  2. git copy
  3. git download
  4. 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?

  1. git fetch
  2. git pull
  3. git merge
  4. 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?

  1. git pull
  2. git fetch
  3. git merge
  4. 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?

  1. git branch
  2. git new
  3. git checkout
  4. git create

Answer: git branch

The git branch command creates a new branch.

13. Which command switches to another branch?

  1. git checkout
  2. git branch
  3. git switchbranch
  4. git move

Answer: git checkout

git checkout <branch-name> switches to another branch.

14. Which command merges one branch into another?

  1. git merge
  2. git combine
  3. git join
  4. git push

Answer: git merge

git merge combines changes from one branch into another.

15. Which command shows the commit history?

  1. git log
  2. git history
  3. git commits
  4. git show

Answer: git log

git log displays the commit history of the repository.

16. Which command removes a file from Git tracking?

  1. git rm
  2. git remove
  3. git delete
  4. 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?

  1. A folder containing project files and Git history
  2. A programming language
  3. A cloud server
  4. 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?

  1. To work on new features without affecting the main code
  2. To delete files
  3. To upload projects
  4. 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?

  1. Pull Request
  2. Fork
  3. Issue
  4. 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?

  1. Version Control
  2. Team Collaboration
  3. Backup of Code
  4. All of the above

Answer: All of the above

Git and GitHub provide version control, collaboration, and secure code backup.

Take the timed quiz