
To revert a commit on the GitHub website, you need to navigate to the repository where the commit was made. From there, click on the three dots next to the commit and select "Revert commit".
You can also revert a commit by clicking on the "Revert this commit" button on the commit's details page. This will create a new commit that undoes the changes made in the original commit.
The revert commit will have the same author and date as the original commit, but with a message indicating that it's a revert.
What to Know
Revert commit on GitHub can be a bit tricky, but don't worry, we've got you covered.
You can revert a commit on GitHub by using the "Revert" button on the commit page, which is located on the right-hand side of the commit message. This will create a new commit that undoes the changes made in the original commit.
To revert a commit, you'll need to have the necessary permissions and access to the repository. If you're a collaborator, you'll need to make sure you have the right permissions set up.
The revert commit will have a different ID and message than the original commit, and it will also be listed as a separate commit in the repository's commit history.
How to Revert
Reverting a commit on GitHub is a straightforward process, but it's essential to understand how it works. Reverting does not take you back to a specific committed state, but rather undoes the changes of a specific commit action.
To revert multiple commits, you must do it one at a time, starting with the most recent. This is because reverting a commit in the middle of the history can lead to incoherence in your repository, which is a Very Bad Idea.
Understanding the Process
Reverting a commit on GitHub Desktop is a straightforward process. You can roll back all changes made in the most recent commit and revert to the previous state of the repository by navigating to the "History" tab, right-clicking on the previous commit, and selecting "Revert This Commit".
A new commit appears in the History tab after successfully reverting a commit, indicating that the state you reverted from still exists in the repository's history. You can revert the revert to get the old files back.
Git revert doesn't move the HEAD and branch ref pointers to the specified commit, but instead updates the ref pointers to point at the new revert commit, making it the tip of the branch. This is a safe operation for commits that have already been published to a shared repository, as it doesn't change the project history.
Old Repository Version
Reverting to an old repository version is a crucial step in managing your code. You can roll back all changes made in the most recent commit and revert to the previous state of the repository in GitHub Desktop.
To do this, navigate to the "History" tab and right-click on the previous commit. You'll see the option to revert this commit.
Reverting a commit is a straightforward process that involves calculating the changes needed to restore the old files, implementing those changes, and then committing them. This creates a new commit in the History tab, while no changes appear in the Changes tab.
The reverted state still exists in the repository's history, allowing you to revert the revert and retrieve the original files if needed.
How It Works
The git revert command is used for undoing changes to a repository's commit history. This is different from other 'undo' commands like git checkout and git reset, which move the HEAD and branch ref pointers to a specified commit.
To demonstrate how it works, let's create an example repo using the command line. This will help us see the process in action.
Git revert takes a specified commit, but it doesn't move the ref pointers to this commit. Instead, it creates a new "revert commit" that inverses the changes from the specified commit.
The ref pointers are then updated to point at the new revert commit, making it the tip of the branch. This is a key difference between git revert and other 'undo' commands.
Common Options

The common options for using git revert are straightforward.
The default option is to open the configured system editor and prompt you to edit the commit message prior to committing the revert.
This option is the inverse of the -e option, meaning the revert will not open the editor.
Passing this option will prevent git revert from creating a new commit that inverses the target commit, instead adding the inverse changes to the Staging Index and Working Directory.
These are the other trees Git uses to manage the repository, and for more info, you can visit the git reset page.
Examples and Discussion
Reverting commits on the GitHub website can be a bit tricky, but it's a useful feature for undoing changes made in previous commits.
To revert a commit, you can use the "Revert" option on the commit page, which will create a new commit that undoes the changes made in the original commit.
You can also revert a range of commits by specifying the commit hashes, for example, reverting the changes done by commits from the fifth last commit in master to the third last commit in master. This will only modify the working tree and the index, without creating a new commit.
It's a good idea to explain why you're reverting a commit in the commit message, as this will help others understand the context. This can be especially helpful if you're reverting a revert, which can create a confusing commit history.
Examples
Reverting changes can be a useful Git technique. You can revert the changes specified by the fourth last commit in HEAD and create a new commit with the reverted changes.
To do this, you can use Git's revert command. This command will create a new commit with the reverted changes. It's a great way to undo changes made in the past.

Reverting a range of commits can also be useful. You can revert the changes done by commits from the fifth last commit in master (included) to the third last commit in master (included), but without creating any commit with the reverted changes. This will only modify the working tree and the index.
This can be a convenient way to review changes without committing them. It's a good option when you want to inspect changes but don't want to record them in the commit history.
Featured Images: pexels.com


