AlgoMaster Logo

Undoing Changes - Quiz

Last Updated: January 3, 2026

Undoing Changes Exercises

30 quizzes

1
Code Completion

Discard local changes in a single tracked file and restore it to the last committed version

shell
1
git src/app.js

Click an option to fill the blank:

2
Code Completion

Undo the last commit but keep all its changes staged for a new commit

shell
1
git reset HEAD~1

Click an option to fill the blank:

3
Code Completion

Create a new commit that reverses the changes introduced by a specific commit

shell
1
git a1b2c3d

Click an option to fill the blank:

4
Code Completion

Remove untracked files and directories that clutter your working directory

shell
1
git clean

Click an option to fill the blank:

5
Code Completion

Temporarily save modified and staged changes so you can switch branches with a clean working directory

shell
1
git

Click an option to fill the blank:

6
Multiple Choice

Which Git area is directly modified when you edit files before staging them?

7
Multiple Choice

What does git reset --hard HEAD~1 do?

8
Multiple Choice

In a shared repository, which command is safest to undo a bad commit on main?

9
Multiple Choice

Which command unstages a file while keeping its changes in the working directory in modern Git?

10
Multiple Choice

What is the main difference between git checkout file.txt and git restore file.txt (with default options)?

11
Sequencing

Order the steps to undo the last commit but keep its changes for editing and recommitting.

Drag and drop to reorder, or use the arrows.

12
Sequencing

Order the steps to temporarily shelve work, fix a bug on main, then resume the shelved work.

Drag and drop to reorder, or use the arrows.

13
Sequencing

Order the steps to clean untracked build artifacts after verifying what will be removed.

Drag and drop to reorder, or use the arrows.

14
Sequencing

Order the steps to revert a specific bad commit in a shared repository.

Drag and drop to reorder, or use the arrows.

15
Output Prediction

HEAD currently points to commit 1234567. What will this command print?

1git rev-parse --short HEAD
16
Output Prediction

You are on branch feature-login. What does this command print?

1git branch --show-current
17
Output Prediction

File config.yml is staged with changes. What will this command print?

1git restore --staged config.yml && echo "done"
18
Output Prediction

There is a single stash entry stash@{0}. What will this command print on success?

1git stash drop stash@{0} && echo "dropped"
19
Bug Spotting

Identify the incorrect command in this attempt to discard local changes and then clean untracked files.

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

shell
1
git status
2
git reset --hard
3
git clean -nfd
4
git clean fd
20
Bug Spotting

Find the incorrect step in this workflow to revert a commit and push the change.

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

shell
1
git log --oneline
2
git revert HEAD~2
3
git push origin HEAD~2
4
git push origin HEAD
21
Bug Spotting

Identify the wrong command in this attempt to unstage and discard changes to a file.

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

shell
1
git add config.json
2
git restore --staged config.json
3
git restore --hard config.json
4
git status
22
Matching

Match each command with what it primarily affects.

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

23
Matching

Match each stash-related command to its purpose.

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

24
Matching

Match the reset mode with its behavior on Git's three areas.

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

25
Fill in the Blanks

Complete the commands to unstage a file and then discard its working directory changes.

shell
1
git --staged settings.yml
2
git settings.yml

Click an option to fill blank 1:

26
Fill in the Blanks

Complete the commands to view and then drop the most recent stash.

shell
1
git stash
2
git stash stash@{0}

Click an option to fill blank 1:

27
Fill in the Blanks

Complete the commands to preview and then perform a clean-up of untracked files and directories.

shell
1
git clean -fd
2
git clean -fd

Click an option to fill blank 1:

28
Hotspot Selection

Select the line that indicates the currently checked-out branch while preparing to undo changes.

Click on the line to select.

shell
1
  feature/login
2
* main
3
  bugfix/reset-issue
29
Hotspot Selection

Select the line that shows an unstaged modification which could be discarded with git restore.

Click on the line to select.

shell
1
On branch feature-api
2
Changes not staged for commit:
3
  (use "git add <file>..." to update what will be committed)
4
  (use "git restore <file>..." to discard changes in working directory)
5
	modified:   src/api/client.js
6
 
7
no changes added to commit (use "git add" and/or "git commit -a")
30
Hotspot Selection

Select the line showing an untracked file that could be removed with git clean.

Click on the line to select.

shell
1
On branch main
2
Untracked files:
3
  (use "git add <file>..." to include in what will be committed)
4
	build/output.log
5
	notes.tmp
6
nothing added to commit but untracked files present (use "git add" to track)