> ## Content Index
> Fetch the complete content index at: https://www.techielass.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Revert those changes in Git
- URL: https://www.techielass.com/git-revert-last-commit/
- Published: 2021-11-23T07:30:00.000Z
- Updated: 2022-01-07T11:32:28.000Z
- Description: Occasionally you'll want to undo a change you've made within Git, let's take a look at how you can do that using the revert command.
- Author: Sarah Lean
- Tags: Git, GitHub, Git for everyone, hacktoberfest, git revert last commit

Continuing on the theme of Git commands you should know. Today I am looking at using **git to revert that last commit.** 

Occasionally you'll want to undo the changes you've just made. And there are various ways to do that either locally or remotely depending on what you need, but you do have to be careful when doing that and avoid unwanted deletions. 

The way I prefer to do this is using **git revert**. 

## Look at the logs

The first thing to do is look back at your logs and find the commit details using the command **git log --oneline**

![Git Log](https://storage.ghost.io/c/08/96/08960c71-63a2-449b-91b1-8d4628166dd2/content/images/2021/10/gitlog.png)

Git Log

## Revert the change

We want the hash number that is next to your latest commits. That little number helps us revert the change we want to make. 

One we have a note of that number we want to issue the command **git revert 7270d13**

You'll be taken into a screen where you can make edits. You should be able to exit using **:wq**

You'll exit the editor and be taken back to your command line where you'll see that the commit that you reverted has been reverted. 

![Git Revert Confirm](https://storage.ghost.io/c/08/96/08960c71-63a2-449b-91b1-8d4628166dd2/content/images/2021/10/gitrevertconfirm.png)

Git Revert Confirm

If you now run **git log --oneline** you'll see a new commit has been created to carry out that revert. 

### Let me know your favourite way to revert a change within Git.