Final exam
Git and GitHub Basics
Before you start
- 20 questions, drawn at random from a pool of 33.
- Pass mark: 70%. Your final score is 30% practice + 70% exam.
- No time limit, but finish within 3 hours. You can move between questions before you submit.
- Failed? Review the lessons and try again: every attempt gets a new set of questions.
Question 1 of 20Choose one
Which statement best describes the relationship between Git and GitHub?
Question 2 of 20True or false
Because Git is distributed, you can commit and view history without an internet connection.
Question 3 of 20Sort into groups
Sort these files for a typical web project repository.
Tap an item, then tap its group (or drag it there).
Question 4 of 20Fill in the blanks
Fill in the blanks
To set the name recorded on your commits in every repository on your computer, run `git config --global user. "Your Name"`.
Question 5 of 20Choose one
A repository-level setting user.email conflicts with your global user.email. Which one does Git use for commits in that repository?
Question 6 of 20Put in order
Put these in the order a new change moves through Git.
Drag the items, or use the arrow buttons, to put them in order.
- Remote repository on GitHub
- Working directory
- Staging area
- Local repository
Question 7 of 20Choose one
git status lists report.md under both "Changes to be committed" and "Changes not staged for commit". What does that mean?
Question 8 of 20True or false
git commit -a includes brand-new files that have never been added.
Question 9 of 20Spot the mistake
Click every commit subject that breaks the common convention (imperative, specific, about 50 characters or fewer, no trailing period).
Question 10 of 20Match the pairs
Match each command to what it shows.
Tap an answer, then tap the place where it belongs (or drag it there).
- git diff
- git diff --staged
- git log --oneline
- git show HEAD
Question 11 of 20Choose one
In a diff, what does a line beginning with + mean?
Question 12 of 20Choose one
You added secrets.txt to .gitignore, but it still appears in commits because it was committed last week. What fixes this going forward?
Question 13 of 20Choose one
Which .gitignore pattern ignores every PDF file anywhere in the repository?
Question 14 of 20What would you do?
What would you do?
You committed locally with a typo in the message and forgot to include one file. You haven't pushed. What's the cleanest fix?
Question 15 of 20Match the pairs
Match each undo-related command to what it does.
Tap an answer, then tap the place where it belongs (or drag it there).
- git restore file.txt
- git restore --staged file.txt
- git revert a1b2c3d
- git reset --hard HEAD~1
- git stash
Question 16 of 20True or false
git revert is safe to use on commits that teammates have already pulled.
Question 17 of 20Choose one
What is a Git branch, technically?
Question 18 of 20Fill in the blanks
Fill in the blanks
The special pointer that marks which branch or commit you currently have checked out is called .
Question 19 of 20Choose one
Git refuses to switch branches because your uncommitted changes would be overwritten. Which option keeps your changes and lets you switch?
Question 20 of 20Choose one
You are on main, which has had no new commits since you created feature. You run git merge feature. What happens?
Question 21 of 20True or false
Two branches that edit different, non-adjacent sections of the same file usually merge without a conflict.
Question 22 of 20Put in order
Put the sections of a conflict block in the order they appear in the file.
Drag the items, or use the arrow buttons, to put them in order.
- The incoming branch's version
- =======
- Your current branch's version
- >>>>>>> other-branch
- <<<<<<< HEAD
Question 23 of 20Choose one
Halfway through resolving a confusing merge conflict, you decide to start over later. Which command returns everything to the state before the merge?
Question 24 of 20Choose one
Which command uploads your local branch add-login to GitHub and sets it to track the remote branch?
Question 25 of 20Choose one
What does git clone set up automatically?
Question 26 of 20What would you do?
What would you do?
Your push to main is rejected because the remote has commits you don't have. A teammate suggests git push --force. What do you do?
Question 27 of 20True or false
git fetch changes the files in your working directory to match the remote.
Question 28 of 20Select all that apply
Which of these happen when you open a pull request on GitHub? Select all that apply.
Select all that apply.
Question 29 of 20Choose one
Which merge option on GitHub combines all of a pull request's commits into a single commit on main?
Question 30 of 20Choose one
You want to contribute a fix to an open-source project where you have no write access. What do you create first?
Question 31 of 20Fill in the blanks
Fill in the blanks
A project at version 3.2.7 under semantic versioning makes a change that breaks backward compatibility. Its next version should be .
Question 32 of 20What would you do?
What would you do?
A teammate pushed a commit containing a cloud access key to your public repository. It's been there for ten minutes. What's the first priority?
Question 33 of 20Match the pairs
Match each repository file or folder to its purpose.
Tap an answer, then tap the place where it belongs (or drag it there).
- README.md
- LICENSE
- .github/workflows/
- CODEOWNERS