Git Command Generator

Undo last commit (keep changes)

git reset --soft HEAD~1

Undoes the last commit but keeps all changes staged. Safe operation.

Undo last commit (discard changes)

git reset --hard HEAD~1

Completely removes the last commit and discards changes. Cannot be undone!

Unstage a file

git restore --staged <file>

Removes a file from the staging area without deleting changes.

Discard file changes

git checkout -- <file>

Reverts a file to its last committed state. Changes are lost.