How to undo or revert last commit(s) in Git

When you are working on git, it is possible that sometimes you may commit the wrong files or the code you committed some times needs to be reverted back.

There are many ways to revert the last commit or any specific commit in git. This SO post has many answers which explains how to revert a commit. But those are to be done in a command prompt which many are un-familiar with. So here am going to explain a easy way to revert a commit in git.

This can be achieved using Git Extensions. You can download it from here link1 or from here link2

Once you download Git Extensions, open it and select the repository where your source code exists.

Once this is done Git Extensions will show you all the commits. Select any specific commit and right click on it. Then select revert commit. Check the below screenshot for reference


Once you select the Revert Commit option, it opens a pop-up like below


Select "Automatically create a commit" if you want to directly commit the reverted changes or if you want to manually commit the reverted changes keep the box un-selected and click on "Revert this commit" button.

In this way you can easily revert any commit in git using Git Extensions.

For more useful articles on git visit this link: Git

No comments:

Post a comment