-6

I accidentally rest my commit in git and I would undo the last commit are their any way to undo last commit in git .

  • I want to undo the last rest .
Mike Mertsock
  • 11,825
  • 7
  • 42
  • 75

2 Answers2

0

You could do this:

git reset --soft HEAD~

This will not remove new files or changes in the files. It only reverts the commit so the commit never happened. If you want the changes not to be in the files use --hard instead of --soft.

Beryllium
  • 12,808
  • 10
  • 56
  • 86
cforbish
  • 8,567
  • 3
  • 28
  • 32
-1

Simply reset the branch to the previous commit, if everything has been done locally.

Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268