Question bank
Pick an answer to see if you're right — with an explanation.
All topicsPythonSQL / MySQLData ScienceNumPyPandasMatplotlibMachine LearningDeep LearningArtificial IntelligenceLarge Language ModelsDjangoAPIsGit & GitHubPower BIExcelStatistics
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
Explanation: restore --staged removes the file from the index while leaving the working-tree changes untouched.
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
Explanation: revert adds a new commit that undoes the change without rewriting shared history.
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
Explanation: Run git rm --cached on the file to untrack it; after that the ignore rule applies.
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
Explanation: GitHub discovers YAML workflow files under .github/workflows/.
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
Explanation: A soft reset moves the branch back but keeps the changes staged, so one new commit replaces the three.
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
Explanation: force-with-lease checks that the remote branch is still where you last saw it before overwriting.
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>
Explanation: cherry-pick applies the changes of a specific commit onto the current branch as a new commit.
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
Explanation: Annotated tags are full objects with metadata, and tags are pushed with git push origin <tag> or --tags.
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
Explanation: Bisect halves the range each step, so log2(1000) is roughly 10 steps.
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
Explanation: bisect run treats exit code 0 as good and most non-zero codes as bad (125 means skip).