๐Ÿ“ Git & GitHub

Undo and Revert in GitHub Desktop: Fix Mistakes Without Fear

P
Author
PyLand Team
๐Ÿ“…
Published
16.07.2026
โฑ๏ธ
Reading time
2 min
๐Ÿ‘๏ธ
Views
358
๐ŸŒฑ
Level
Beginner

A commit is not a point of no return. GitHub Desktop lets you rebuild a local commit with Undo or safely reverse a published commit with Revert.


First question: was the commit pushed?

  • No, it is still local โ†’ use Undo.
  • Yes, it is already on GitHub โ†’ use Revert.

Undo: rebuild a local commit

Undo removes the latest local commit from History but keeps every file change. The files return to Changes so you can review, improve, and commit them again.

Method 1: from Changes

  1. Open Changes.
  2. Find the latest local commit at the bottom of the sidebar.
  3. Click Undo.
  4. Confirm the files returned to Changes.

Method 2: from History

Some GitHub Desktop versions expose Undo in the context menu of the latest unpushed commit.

  1. Open History.
  2. Right-click the latest local commit.
  3. Select Undo commit if available.
  4. Return to Changes and inspect the files.

Undo is not Discard changes. Undo keeps edits; Discard changes removes uncommitted edits.

Revert: reverse a published commit

If a commit is already on GitHub, do not rewrite shared history. Revert creates a new commit with the opposite changes.

  1. Open History.
  2. Right-click the published commit.
  3. Select Revert Changes in Commit.
  4. Open the new Revert commit and read its reverse diff.
  5. Click Push origin.

The original commit remains visible. The new commit records its safe correction.

Undo versus Revert

Situation Tool Result
Latest commit is local Undo Commit is unpacked; edits return to Changes
Commit is published Revert A new reverse commit is created
Remove uncommitted edits Discard changes Edits are deleted โ€” use carefully

Revert does not remove secrets

If a password, token, private key, or API key was committed, Revert does not make it safe. The original value remains in Git history.

  1. Treat the secret as exposed.
  2. Revoke or rotate it immediately.
  3. Remove it from the current project version.
  4. Ask a responsible developer or mentor to help clean Git history.
  5. Never publish a real secret again to test the fix.

Checklist

  • I checked whether the commit was pushed.
  • I chose Undo for a local commit.
  • I chose Revert for a published commit.
  • I reviewed the diff before and after.
  • I will not rely on Revert to protect a leaked secret.

Your reaction to the article

๐Ÿ’ฌ Comments (0)

๐Ÿ” Sign in to leave a comment
๐Ÿšช Login
๐Ÿ’ญ

No comments yet

Be the first to share your opinion about this article!

๐Ÿ”— Similar

Similar articles

Continue learning with these materials

๐Ÿ“

History, Diffs, and Web Commits on GitHub

GitHub lets you read repository history, inspect individual commit diffs, view the history of one...

๐Ÿ“… 16.07.2026 ๐Ÿ‘๏ธ 311
๐Ÿ“

Your First Git Commit

Your first commit starts with initializing a repository, configuring the author identity, and selecting the...

๐Ÿ“… 30.06.2026 ๐Ÿ‘๏ธ 341
๐Ÿ“

Git Hosting Platforms

GitHub, GitLab, Bitbucket โ€” key differences and recommendations.

๐Ÿ“… 06.05.2026 ๐Ÿ‘๏ธ 554
๐ŸŽ“ Continue learning

Courses that cover this material

Visit the course to apply this material in practice.

Git & GitHub Desktop: Teamwork Without the Pain Open course curriculum