Thuta Learning
Git
AdvancedDevOps & ToolsBeginner

Undoing Changes (reset)

GitLesson 19

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)

Updated on

Progress is saved only in this browser on this device. It isn't synced to other devices.

Report a problem with this lessonOpens your email app with this lesson's address filled in — nothing is sent until you send it.

Undoing Changes (reset) | Thuta Learning