Skip to main content

Undoing things in Git: restore, reset, revert and reflog

Undo a change at any stage, from an unsaved edit to a pushed commit, choose between reset and revert, and recover work with the reflog.

Beginner 3 · Data and toolsabout 1 hour5 sections

Quick answer

Use restore for uncommitted edits, reset for your own unpushed commits, revert for pushed commits, and the reflog to find work you thought was lost.

Why it matters

Everyone commits the wrong thing sooner or later. Knowing the safe undo for each situation is what lets you fix it in a minute instead of breaking main or losing a day's work.

Sign up free to read the whole lesson

The rest of this lesson: 5 parts, video lessons, the best course, practice and a quick check. It is free, takes a few seconds and needs no card.

Accounts are for learners aged 18 and over. Under 18? The quick answer and the first part of every lesson stay open: browse lessons by topic.

Software engineeringBeginner 3: Data and toolsVideo lessonsGit resetGit revertCommit

Track

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.