Question bank

Pick an answer to see if you're right — with an explanation.

Git & GitHubEasy
Which command unstages a file but keeps your edits?
agit restore --staged file.py
bgit reset --hard
cgit revert file.py
dgit rm file.py
Git & GitHubEasy
A commit already pushed to `main` introduced a bug. What is the safest way to undo it?
agit reset --hard HEAD~1 and force-push
bgit revert <sha>
cDelete the repository
dgit commit --amend
Git & GitHubEasy
Why doesn't adding `db.sqlite3` to `.gitignore` stop Git from tracking it?
a.gitignore only works on Windows
bPatterns need a leading slash
cThe file is already tracked; .gitignore only affects untracked files
dSQLite files cannot be ignored
Git & GitHubEasy
Where do GitHub Actions workflow files live?
aIn the repo root as actions.yml
bIn GitHub account settings only
cIn a .git/hooks folder
dIn the .github/workflows/ directory
Git & GitHubMedium
What does this sequence do?
git reset --soft HEAD~3
git commit -m "Add GST report"
aDeletes the last three commits and their changes
bReverts three commits on the remote
cSquashes the last three commits into one, keeping all changes
dCreates three new branches
Git & GitHubMedium
Why is `git push --force-with-lease` preferred over `git push --force` after a rebase?
aIt refuses to overwrite commits someone else pushed since your last fetch
bIt is faster
cIt also pushes tags
dIt avoids the need to rebase
Git & GitHubMedium
You need one bug-fix commit from `develop` on `release/2.3` without merging everything else. Use…
agit stash
bgit bisect
cgit rebase develop
dgit cherry-pick <sha>
Git & GitHubMedium
Which statement about tags is correct?
agit push sends all tags by default
bAnnotated tags store author, date and a message; tags must be pushed explicitly
cTags move forward with each new commit
dTags can only point to the latest commit
Git & GitHubHard
Roughly how many test steps does `git bisect` need to find a bad commit among about 1,000 commits?
aAbout 10
bAbout 100
cAbout 500
dAbout 1,000
Git & GitHubHard
What does `git bisect run` use to decide whether each commit is good or bad?
git bisect start HEAD v2.1.0
git bisect run python manage.py test billing
aThe commit message
bWhether the files changed
cThe exit code of the command: 0 is good, non-zero is bad
dThe author of the commit