-4

Can you tell me how i can undo every change i have made since my last commit, delete anything newer and return to my last commit?

Neither git checkout df60bb or git reset HEAD --hard worked . At least one file (RoR migration file) which wasnt part of the last commit remains after these two commands

Thanks

aptbs85
  • 101
  • 1
  • 1
  • 7

1 Answers1

0

First, go back to the root directory of your project. Then, do

git reset HEAD .
git checkout -- .

What this will do is unstage any changes that are currently staged, and then undo any unstaged changes to tracked files. To delete untracked files, do:

rm $(git ls-files --others --exclude-standard)

Which will find all the files and then shell-expand them for deletion.

It should also be noted that, if you have files that are being generated, it's usually a good idea to add them to your .gitignore file so you don't have to constantly be deleting them.

Sebastian Lenartowicz
  • 4,695
  • 4
  • 28
  • 39