0 votes
in Git by

How to revert the previous commit in git?

1 Answer

0 votes
by
git reset --hard HEAD~N- To undo last commit and changes.N stands for how far you would like to undo your changes. For undo last changes N=1 Let's talk about below use case where C is current HEAD while F is a state of files.

  (F)

A-B-C

   ↑

 master

If you like to undo commit C. You do this:

git reset --hard HEAD~1

The result is:

(F)

A-B

 ↑

master

Related questions

+1 vote
asked Oct 15, 2019 in Git by rajeshsharma
0 votes
asked Feb 17, 2020 in Git by SakshiSharma
...