AlgoMaster Logo

Git Best Practices - Quiz

1 min readUpdated December 2, 2025
Listen to this chapter
Unlock Audio

Git Best Practices Exercises

29 quizzes

1
Code Completion

Record staged changes with a clear message in an atomic commit

shell
1
git commit - "Implement payment validation"

Click an option to fill the blank:

2
Code Completion

Create a new feature branch from the current branch following a branching strategy

shell
1
git feature/add-audit-logging

Click an option to fill the blank:

3
Code Completion

Stage only part of a file to keep a commit atomic

shell
1
git add - src/auth/login.js

Click an option to fill the blank:

4
Code Completion

Define a local .gitignore entry to avoid committing environment files

shell
1
echo ".env" >> .git

Click an option to fill the blank:

5
Code Completion

Configure Git to sign all commits for better security and auditability

shell
1
git config --global commit.gpgsign

Click an option to fill the blank:

6
Multiple Choice

Which commit message best follows Conventional Commits and explains the intent?

7
Multiple Choice

Why are atomic commits recommended for keeping history clean?

8
Multiple Choice

In a Git Flow-style workflow, which branch should contain production-ready code?

9
Multiple Choice

Which file is the best place to prevent committing API keys stored in a .env file?

10
Multiple Choice

After accidentally committing a password, what is the safest first action?

11
Sequencing

Order the steps to create a small, atomic commit for a single bug fix on main

Drag and drop to reorder, or use the arrows.

12
Sequencing

Order the steps to squash feature branch commits into one before merging to main

Drag and drop to reorder, or use the arrows.

13
Sequencing

Order the workflow to introduce a hotfix using a Git Flow-style branching strategy

Drag and drop to reorder, or use the arrows.

14
Sequencing

Order the steps to add a commit-msg hook that enforces Conventional Commit headers

Drag and drop to reorder, or use the arrows.

15
Output Prediction

You are currently on branch feature/login. What will this command output?

1git branch --show-current
16
Output Prediction

Your last commit message was "fix: handle null tokens". What will this command print?

1git log -1 --pretty=%s
17
Output Prediction

You have an environment variable GIT_BRANCH_NAME set to "secure-deploy". What does this print?

1git config branch.current.name
18
Bug Spotting

Identify the incorrect command in this attempt to create an atomic commit for a docs update

Click on the line(s) that contain the bug.

shell
1
git checkout docs-update
2
git add docs/*.md
3
git commit -m docs: update api usage
4
git push origin docs-update
19
Bug Spotting

Find the incorrect command in this workflow to rebase a feature branch onto main

Click on the line(s) that contain the bug.

shell
1
git checkout main
2
git pull origin main
3
git rebase feature/login
4
git checkout feature/login
5
git rebase main
20
Bug Spotting

Spot the mistake in this attempt to ignore secrets and keep them out of history

Click on the line(s) that contain the bug.

shell
1
echo "API_KEY=secret" > .env
2
echo ".env" > .gitignore
3
git add .env .gitignore
4
git commit -m "chore: add local env file"
5
GIT_TRACE_SECRETS=1 git commit -m "chore: enable secret tracing"
21
Matching

Match each command or concept with its primary purpose in keeping history clean

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

22
Matching

Match Conventional Commit types to typical use cases

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

23
Matching

Match security-related Git practices with their purpose

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

24
Fill in the Blanks

Complete the commands to create a feature branch and push it to origin following an atomic commit workflow

shell
1
git checkout
2
git checkout -b
3
git push -u origin

Click an option to fill blank 1:

25
Fill in the Blanks

Fill in the commands to configure a global .gitignore to avoid committing OS and editor files

shell
1
git config --global ~/.gitignore_global
2
echo "*.swp" >>

Click an option to fill blank 1:

26
Fill in the Blanks

Complete the commands to enable GPG signing and verify the latest commit

shell
1
git config --global commit.gpgsign
2
git log -1

Click an option to fill blank 1:

27
Hotspot Selection

Click the line that shows the currently checked-out branch in this branch list

Click on the line to select.

shell
1
  main
2
* develop
3
  feature/login
4
  hotfix/urgent-bug
28
Hotspot Selection

Click the part of git status output that shows an untracked secrets file that should be added to .gitignore

Click on the line to select.

shell
1
On branch feature/payments
2
Untracked files:
3
  (use "git add <file>..." to include in what will be committed)
4
	.env.local
5
	src/new-file.js
6
nothing added to commit but untracked files present
29
Hotspot Selection

Click the line that indicates a commit introduces a breaking change according to Conventional Commits

Click on the line to select.

shell
1
commit 2f3e9b1
2
Author: Dev <dev@example.com>
3
Date:   Tue Jul 9 12:34:56 2024 +0000
4
 
5
    feat(auth)!: switch to new token service
6