Thuta Learning
AdvancedDevOps & Toolsbeginner

Undoing Changes (reset)

Relax. We'll talk through this in plain words — no textbook voice.

git reset command rewrites project history — for example, to undo the last commit. Because it rewrites history, be careful when resetting commits that are already public (pushed).

bash
# Resets the staging area and working directory to the last commit
# --hard flag is destructive and will delete your uncommitted changes!
git reset --hard HEAD

# Moves HEAD back one commit, keeping the changes in the working directory
git reset HEAD~1
You should see
(A powerful command that can rewrite commit history — use it carefully)