-2

I have used Git to view some older files using the git checkout <hash> command.

However, now I want to move the head back to the latest commit without saving the changes I did at the older files.

Could you help on how to do that?

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
erwindenboer
  • 111
  • 1
  • 10

1 Answers1

1

You did not explain you needs, so I am trying to guess...

Try with:

git reset --soft HEAD~1

# or

git reset --soft <COMMIT_ID>

Rembember --soft leave changes as uncommitted in order to inspect without loosing them.

Replace it with --hard if you need to discard them.

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74