Are you confident in your Git skills? A Git quiz is a perfect way to challenge your understanding of version control concepts and commands. Whether you’re a beginner or an experienced developer, this quiz will test your knowledge and help you identify areas for improvement.
For more Git tutorials, resources, and quizzes, visit The Coding College and become a Git expert!
Git Quiz Instructions
- Each question has multiple-choice answers.
- Choose the correct option based on your knowledge.
- Check the answers at the end of the quiz to see how well you did.
Beginner-Level Questions
1. What does git init
do?
a) Initializes a new Git repository.
b) Creates a new branch.
c) Stages changes for commit.
d) Merges two branches.
2. Which command is used to check the status of your working directory?
a) git log
b) git status
c) git branch
d) git diff
3. What does git add
do?
a) Commits changes to the repository.
b) Stages changes for the next commit.
c) Creates a new branch.
d) Deletes a file from the repository.
4. How do you create a new branch in Git?
a) git new-branch
b) git branch <branch-name>
c) git checkout <branch-name>
d) git init <branch-name>
5. What is the purpose of .gitignore
?
a) To delete files from the repository.
b) To ignore specific files or directories from being tracked by Git.
c) To create a new branch.
d) To merge branches.
Intermediate-Level Questions
6. How do you undo the last commit while keeping the changes?
a) git reset --hard HEAD~1
b) git revert HEAD
c) git reset --soft HEAD~1
d) git stash
7. Which command shows the commit history?
a) git log
b) git show
c) git branch
d) git status
8. What does git merge
do?
a) Deletes a branch.
b) Combines changes from two branches.
c) Resolves conflicts.
d) Stages changes for commit.
9. What is the default branch in a newly initialized Git repository?
a) master
b) main
c) develop
d) default
10. How do you clone a remote repository?
a) git copy <URL>
b) git download <URL>
c) git clone <URL>
d) git fetch <URL>
Advanced-Level Questions
11. Which command saves uncommitted changes temporarily?
a) git stash
b) git reset
c) git checkout
d) git revert
12. How do you resolve a merge conflict?
a) Delete the conflicting branch.
b) Use git merge --force
.
c) Edit the conflicting files, stage the changes, and commit.
d) Revert to a previous commit.
13. What does git rebase
do?
a) Creates a new branch.
b) Changes the base of a branch to a different commit.
c) Deletes a branch.
d) Combines two commits into one.
14. How do you fetch changes from a remote repository without merging them?
a) git pull
b) git fetch
c) git sync
d) git clone
15. What does the HEAD
pointer represent in Git?
a) The last commit on the default branch.
b) The current branch you’re working on.
c) The topmost commit in the repository.
d) The previous commit.
Answer Key
- Beginner-Level:
- a
- b
- b
- b
- b
- Intermediate-Level:
6. c
7. a
8. b
9. b
10. c - Advanced-Level:
11. a
12. c
13. b
14. b
15. b
Conclusion
How did you score? Whether you aced it or learned something new, practicing Git quizzes regularly will solidify your knowledge and boost your confidence.