How to revert commit in Git

Article autor
September 9, 2025
How to revert commit in Git
Elixir Newsletter
Join Elixir newsletter

Subscribe to receive Elixir news to your inbox every two weeks.

Oops! Something went wrong while submitting the form.

Table of contents

Did you ever create a commit that you wish never happened? Let's be honest - we all did. There is an easy way to revert it in Git.

It's as easy as performing git revert operation in console:

git revert [here comes the commit id]

Let's say, your commit id is 17hg8w. You would call it like this:

git revert 17hg8w

Note that this operation creates a new commit that reverts all of the changes instead of removing given commit from history.

Related posts

Dive deeper into this topic with these related posts

No items found.

You might also like

Discover more content from this category

How to check if a set contains exact values with Jest in JS?

TLDR: With jest-extended package you can write: expect([...set]).toIncludeSameMembers([value1, value2]);. If you are looking to a native, but longer solution scroll down a bit.

How to create and use custom shell commands?

Each of us had a situation, where we had to invoke a few, same commands each time. Making it once is not that problematic, but when we are supposed to repeat given operations, it may be better just to create one function that will handle it all.

How to install local npm package in a project

In some cases, like for testing purposes, you might want to use an npm package stored on a local machine. Here is how you can do that with one simple command.