hello! to revert a commit in a GitHub repository all you have to do is,

i. identify the commit to revert: find the commit hash of the commit you want to revert. you can do this by viewing the commit history either on GitHub or locally.

ii. revert the commit using the GitHub interface: on the GitHub repository page, click on the "Commits" tab and find the commit you want to revert. click on the commit to view its details and then click the "Revert" button. this will create a new commit that undoes the changes introduced by the selected commit.

iii. revert the commit locally and push the changes: if you prefer to revert the commit locally you can use git commands. first checkout the branch where the commit exists. then use the command git revert to create a new commit that undoes the changes. and finally push the changes to the repository.

iv. push the changes: if you reverted the commit locally, don't forget to push the changes to the GitHub repository.

if there's anything else you want to know and clarify let me know. : )

🌐
TheServerSide
theserverside.com › tutorial › How-to-git-revert-a-commit-A-simple-undo-changes-example
How to revert a Git commit: A simple example | TheServerSide
The purpose of the git revert command is to remove all the changes a single commit made to your source code repository. For example, if a past commit added a file named index.html to the repo, a git revert on that commit will remove the index.html ...
Discussions

Revert commit on Website
Select Topic Area Question Body Hello there! I'm beginner on GitHub, and can't resolve one problem - on desktop version i can "Revert changes in commit" in history without problem... More on github.com
🌐 github.com
8
18
How do I revert a commit in a GitHub repository?
Select Topic Area Question Body Could someone explain me the procedure concisely? More on github.com
🌐 github.com
3
2
March 12, 2024
How to use Git Revert - Stack Overflow
How is git revert used? This might sound like a duplicate question but when people ask it, the response is often, use git reset as per Revert to a commit by a SHA hash in Git?. Then when someone as... More on stackoverflow.com
🌐 stackoverflow.com
revert to previous commit on github?
As a general rule, once you push your repository to a remote repository, your commits should be considered permanent. By resetting your repository to an earlier state, you made it impossible to push to the remote repository. You have a couple options: git push -f will override that rule and allow you to push. I don't recommend this option unless you're the only user of that remote repository. If other people have been pulling from that repository, you will very likely mess them up. You also might not have the necessary permissions to do this if this is someone else's repository. Go back to where you before you executed git reset --hard and do it right. You could execute these steps: commands: git branch foo (makes a placeholder to where you are now) git pull (get your local repository back in sync with the remote) git revert git push What git revert does is construct a whole new commit that un-does the one you want to get rid of. The old one remains in the git history and then there's a new commit that reverses it. There's no way to really get rid of the old one since it's there in the remote repository and in the repositories of anybody who's pulled from it. If what you want to do something more complicated than just reverting one commit, then there is where branch "foo" comes in: git branch foo (makes a placeholder to where you are now) git pull (get your local repository back in sync with the remote) git diff HEAD foo > /tmp/patch patch -p1 < /tmp/patch git commit -a git push If it's not obvious, what this does is construct a patch that will change all the files in your current branch to what they were in your "reverted" branch. Then you apply that patch and commit the changes. My notes on the subject: http://www.efalk.org/Docs/Git/merging.html Disclaimer: these are Unix commands. If you're on Windows, you're on your own here. More on reddit.com
🌐 r/git
3
0
January 17, 2025
🌐
GitHub
docs.github.com › en › desktop › managing-commits › resetting-to-a-commit-in-github-desktop
Resetting to a commit in GitHub Desktop - GitHub Docs
If you made a series of commits and want to fix a mistake you made prior to the most recent commit, you can use "reset to commit" in GitHub Desktop to reset the changes in those commits. Resetting to a commit restores the changes in the subsequent commits to your working directory and resets the branch to the selected commit.
🌐
Sander Volbeda
sandervolbeda.com › home › technical cro › revert git commit, 2 simple ways
Revert Git commit (GitHub example)
February 28, 2024 - git revert 5cfc208de9dd834e4625c42d29639840c910f969 · Paste the line in the terminal, and it should all work fine. To undo your last commit on the branch you’re on, there is an easier code.
🌐
Git
git-scm.com › docs › git-revert
Git - git-revert Documentation
This requires your working tree to be clean (no modifications from the HEAD commit). Note: git revert is used to record some new commits to reverse the effect of some earlier commits (often only a faulty one). If you want to throw away all uncommitted changes in your working directory, you should see git-reset[1], particularly the --hard option.
🌐
GitHub
github.com › orgs › community › discussions › 60023
Revert commit on Website · community · Discussion #60023
To revert a commit you can git reset --hard<commit-hash> then git push origin <branch-name>, where would likely be main for you as I assume you don't know much about branching yet.
Find elsewhere
🌐
GitHub
docs.github.com › en › desktop › managing-commits › undoing-a-commit-in-github-desktop
Undoing a commit in GitHub Desktop - GitHub Docs
You can undo multiple sequential commits up to a commit that has already been pushed to the remote repository by selecting a previous commit and using the "reset to commit" option. For more information, see Resetting to a commit in GitHub Desktop. To undo a pushed commit without disrupting commit history for other contributors, you can revert the commit.
🌐
GitHub
gist.github.com › gunjanpatel › 18f9e4d1eb609597c50c2118e416e6a6
Git HowTo: revert a commit already pushed to a remote repository · GitHub
If you have the master branch checked out locally, you can also do it in two simpler steps: First reset the branch to the parent of the current commit, then force-push it to the remote. ... This document is inspired by http://christoph.ruegg.name/blog/git-howto-revert-a-commit-already-pushed-to-a-remote-reposit.html - Thank you.
🌐
W3Schools
w3schools.com › git › git_revert.asp
Git Revert
Resized image 5a04b6f Updated README.md ... Hello World! Once you've found the commit you want to undo, use git revert to create a new commit that reverses the changes:...
Top answer
1 of 7
389

git revert makes a new commit

git revert simply creates a new commit that is the opposite of an existing commit.

It leaves the files in the same state as if the commit that has been reverted never existed. For example, consider the following simple example:

$ cd /tmp/example
$ git init
Initialized empty Git repository in /tmp/example/.git/
$ echo "Initial text" > README.md
$ git add README.md
$ git commit -m "initial commit"
[master (root-commit) 3f7522e] initial commit
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
$ echo "bad update" > README.md 
$ git commit -am "bad update"
[master a1b9870] bad update
 1 file changed, 1 insertion(+), 1 deletion(-)

In this example the commit history has two commits and the last one is a mistake. Using git revert:

$ git revert HEAD
[master 1db4eeb] Revert "bad update"
 1 file changed, 1 insertion(+), 1 deletion(-)

There will be 3 commits in the log:

$ git log --oneline
1db4eeb Revert "bad update"
a1b9870 bad update
3f7522e initial commit

So there is a consistent history of what has happened, yet the files are as if the bad update never occurred:

$ cat README.md 
Initial text

It doesn't matter where in the history the commit to be reverted is (in the above example, the last commit is reverted - any commit can be reverted).

Closing questions

do you have to do something else after?

A git revert is just another commit, so e.g. push to the remote so that other users can pull/fetch/merge the changes and you're done.

Do you have to commit the changes revert made or does revert directly commit to the repo?

git revert is a commit - there are no extra steps assuming reverting a single commit is what you wanted to do.

Obviously, you'll need to push again and probably announce your balls-up to the team.

Indeed - if the remote is in an unstable state - communicating to the rest of the team that they need to pull to get the fix (the reverting commit) would be the right thing to do :).

2 of 7
136

Use Git revert like so:

git revert <insert bad commit hash here>

git revert creates a new commit with the changes that are rolled back. git reset erases your Git history instead of making a new commit.

The steps after are the same as any other commit.

🌐
Reddit
reddit.com › r/git › revert to previous commit on github?
r/git on Reddit: revert to previous commit on github?
January 17, 2025 -

Hi, I would like to revert to a previous commit. I believe I did this correctly on my local repository using git reset --hard commit-hash. I would like to push this to github but of this results in

error: failed to push some refs to 'https://github.com/shmish/smartmark.git'
hint: Updates were rejected because the tip of your current branch is behind

I am the only working on this repository, so I am not worried about conflicts, I am trying to move back one commit.

Top answer
1 of 2
14
As a general rule, once you push your repository to a remote repository, your commits should be considered permanent. By resetting your repository to an earlier state, you made it impossible to push to the remote repository. You have a couple options: git push -f will override that rule and allow you to push. I don't recommend this option unless you're the only user of that remote repository. If other people have been pulling from that repository, you will very likely mess them up. You also might not have the necessary permissions to do this if this is someone else's repository. Go back to where you before you executed git reset --hard and do it right. You could execute these steps: commands: git branch foo (makes a placeholder to where you are now) git pull (get your local repository back in sync with the remote) git revert git push What git revert does is construct a whole new commit that un-does the one you want to get rid of. The old one remains in the git history and then there's a new commit that reverses it. There's no way to really get rid of the old one since it's there in the remote repository and in the repositories of anybody who's pulled from it. If what you want to do something more complicated than just reverting one commit, then there is where branch "foo" comes in: git branch foo (makes a placeholder to where you are now) git pull (get your local repository back in sync with the remote) git diff HEAD foo > /tmp/patch patch -p1 < /tmp/patch git commit -a git push If it's not obvious, what this does is construct a patch that will change all the files in your current branch to what they were in your "reverted" branch. Then you apply that patch and commit the changes. My notes on the subject: http://www.efalk.org/Docs/Git/merging.html Disclaimer: these are Unix commands. If you're on Windows, you're on your own here.
2 of 2
4
I am the only working on this repository, so I am not worried about conflicts In this case, a git reset … followed by a git push --force-with-lease is totally fine. (note: a simple push -f would also work, but you should get into the habit of using force-with-lease for later.
🌐
Storylane
storylane.io › tutorials › how-to-revert-to-a-previous-commit-in-github
How to Revert to a Previous Commit in Github: 1-Min Guide
June 5, 2026 - Using the git revert command with a commit's unique hash is the recommended non-destructive way to roll back code in any repository. Go to your repository on GitHub and click on the Commits link.
🌐
Atlassian
atlassian.com › git › tutorials › undoing changes › git revert
How to Revert a Commit in Git? | Atlassian Git Tutorial
Second, git revert is able to target an individual commit at an arbitrary point in the history, whereas git reset can only work backward from the current commit. For example, if you wanted to undo an old commit with git reset, you would have to remove all of the commits that occurred after the target commit, remove it, then re-commit all of the subsequent commits.
🌐
TMS Outsource
tms-outsource.com › home › how to revert to a previous commit in github
How to Revert to a Previous Commit in GitHub - TMS Outsource
December 14, 2025 - To revert using GitHub Desktop, click History in the left sidebar, right-click the target commit, and select “Revert changes in commit” which creates a new commit that undoes the selected changes without command line interaction.
🌐
Rosettacommons
docs.rosettacommons.org › docs › latest › internal_documentation › Reverting-a-Commit
Reverting a Commit
Note that we'll also need the mainline version for the version prior to the commit we're reverting. 56494 - 199441208b2b2f2 56493 - 12a020b263aaafa 56492 - c4ba068409eef69 · (Note for git SHA1's you can shorten them as long as the shortened portion is unique in the repository.) ... Do a "git show" to make sure that your working directory is clean. For safety, we'll do the reversion in a branch. As it's quick, we'll just do a local branch rather than the GitHub personal-tracked-branch
🌐
GeeksforGeeks
geeksforgeeks.org › git › how-to-revert-a-commit-with-git-revert
How To Revert A Commit With Git Revert? - GeeksforGeeks
July 30, 2025 - Instead of deleting or rewriting history, Git provides the git revert command to safely undo a specific commit by creating a new one that reverses its changes. This method maintains a clear and auditable project history, making it ideal for collaborative shared repositories. In this article, we will explain how git revert works, how it is different from git reset, and how to use it effectively with examples and options.
🌐
Graphite
graphite.com › guides › git-revert-commit-after-pushing
git revert commit after pushing - Graphite
Sometimes, after pushing changes, you may need to undo these changes due to errors, or other unintended consequences. This guide will explore how to effectively revert a commit after it has been pushed to a remote repository, covering several methods and best practices.
🌐
GitKraken
gitkraken.com › home › learn › problems & solutions › how to revert a git commit
Git Revert Commit | Solutions to Git Problems
February 5, 2024 - Learn how to use Git revert to undo changes introduced in a specified commit or group of commits. See examples of Git revert commit in the terminal, GitKraken Client, & GitLens.