DEV Community

Dedar Alam
Dedar Alam

Posted on

How to revert git commit easily

First check the git log by running the command git log --oneline

git log screen shot

Here you can see last six commit of this git repository.

add hello file this commit for add the hello file
and after this commit last five commit i add five line

Now i want to revent the line 5 commit.
I add this line on 1009bb3 add line 5 commit.
here
1009bb3 - commit hash
add line 5 - commit message

so next step is run revert command git revert --no-commit <commit hash>
here our revert command is git revert --no-commit 1009bb3

revert commit run screen shot

After run the revert commit, line 6 is gone. now i have to commit the revert commit changes

commit all the revert commit changes screen shot

here commit all the changes after run revert commit

after revert commit git log screen shot

now time to check git log. now here one new commit add Revert "add line 5"


Reference Source

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

The best way to debug slow web pages cover image

The best way to debug slow web pages

Tools like Page Speed Insights and Google Lighthouse are great for providing advice for front end performance issues. But what these tools can’t do, is evaluate performance across your entire stack of distributed services and applications.

Watch video

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay