Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To reverse a pushed commit safely, create a new commit that undoes its changes rather than deleting the original. In GitHub Desktop, use History > right-click the commit > Revert Changes in Commit. To undo a merged pull request on GitHub.com, open it and select Revert; GitHub creates a new pull request that you must merge.

Choose the right way to undo the change

Situation Use What happens
A pushed commit may already be part of other contributors’ work Revert A new commit reverses the change while preserving the original commit in history. GitHub advises avoiding changes to pushed history because collaborators may have based work on it. GitHub’s commit-management guidance explains the distinction.
The latest commit is unpushed, and you want to keep editing its changes Undo in GitHub Desktop Desktop resets the branch to the prior commit and restores the changes to your working directory. Undo is for commits that have not been pushed. See GitHub Desktop’s commit options.
You want to back out several recent, unpushed commits to an earlier point Reset to commit in GitHub Desktop The branch moves to the selected earlier commit, and subsequent changes return to the working directory so you can edit or discard them. GitHub documents this option.
A merged pull request needs to be reversed through GitHub.com Revert on the pull request GitHub opens a new pull request that reverses the original merge commit. Merge the new pull request to apply the reversal. GitHub’s pull-request instructions cover this workflow.

These operations are not interchangeable: a revert records a reversal in history, while Undo and Reset to commit change the branch and working directory for unpushed work.

Revert an individual commit in GitHub Desktop

  1. Open the repository in GitHub Desktop.
  2. Select History in the left sidebar.
  3. Find the commit to reverse, right-click it, and choose Revert Changes in Commit.
  4. Review the resulting changes, then commit the reversal according to your workflow.

The reversal is itself a commit; the original remains in the repository’s history. GitHub’s GitHub Desktop documentation describes the steps and history behavior. If you are reversing several commits, start with the newest and work backward to reduce the risk of conflicts.

Revert a merged pull request on GitHub.com

  1. In the repository, select Pull requests.
  2. Open the merged pull request you want to reverse.
  3. Near the bottom of the page, select Revert.
  4. Review the new pull request GitHub creates, then merge it to apply the reversal.

You need write permission to use this action. If Revert is not available, ask a repository administrator for write access. If GitHub cannot create the reversal because of merge conflicts, or the original pull request was not merged on GitHub, you may need to revert its individual commits instead. GitHub’s pull-request guide documents these conditions.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What a revert does—and does not do

A revert adds a new commit whose changes reverse an earlier commit; it does not erase that earlier commit. This makes it the history-preserving choice when the change has been pushed and other people may have built work on it.

Reverting a commit does not necessarily restore the repository to an earlier snapshot. Later commits may depend on or modify the same lines, so inspect the resulting diff and resolve any conflicts before relying on the result. For a merged pull request, the web action creates a separate pull request that still needs review and merging.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Can you revert an individual commit directly on GitHub.com?

GitHub’s documented web workflow here covers reverting a merged pull request. For an individual commit, the documented step-by-step method is in GitHub Desktop. The available documentation does not establish that GitHub.com provides a direct revert control for an individual commit in every repository or product context.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.