Git Quiz

Thirty questions covering the whole course. Choose an answer for each, then press Check answers at the bottom to see your score and an explanation for every question.

1. What is the relationship between Git and GitHub?

2. Which command sets your name for every repository on your computer?

3. What does git init create?

4. What is the staging area?

5. In git status -s, what does MM before a file mean?

6. Which command stages modified and deleted tracked files, but not new files?

7. Which commit summary follows the usual conventions best?

8. What does git diff --staged show?

9. What does HEAD~2 refer to?

10. A file was committed before you added it to .gitignore. How do you stop tracking it but keep it on disk?

11. Which command discards uncommitted edits to pancakes.txt?

12. When is it safe to use git commit --amend?

13. What does git reset --soft HEAD~1 do?

14. You need to undo a commit that is already on the shared main branch. What should you use?

15. You ran git reset --hard HEAD~3 by mistake. What helps you get the commits back?

16. What is a branch in Git?

17. What happens in a fast-forward merge?

18. Which lines does Git add to a file with a merge conflict?

19. What is the "golden rule" of rebasing?

20. In an interactive rebase, which command combines a commit with the previous one and discards its message?

21. When is git cherry-pick the right tool?

22. What does git stash -u include that plain git stash doesn't?

23. What does git push -u origin feature do besides pushing?

24. What is the difference between git fetch and git pull?

25. What is origin/main?

26. Why prefer git push --force-with-lease over git push --force?

27. After a pull request is squash-merged, why does git branch -d feature say the branch is not fully merged?

28. Which kind of tag should you use for a release?

29. What does git bisect do?

30. You accidentally pushed a commit containing a live API key. What's the first thing to do?