How do you discard unstaged changes in a file named app.js?

git reset app.js
git restore app.js
git revert app.js

Which command removes a file from the staging area without changing its working copy?

git restore —staged app.js
git reset —hard app.js
git commit —amend

What does git commit --amend typically change?

The last commit, replacing it with a new one
It creates a merge commit
It deletes the last commit

Which command is safest to undo a public commit on main?

git reset —hard HEAD~1
git revert <commitSHA>
git switch -c undo

What is the effect of git reset --hard HEAD~1?

Moves HEAD but keeps working tree
Only unstages files
Moves HEAD and discards index and working tree changes