Search code examples
gitcommitrevert

Git - how to roll back all changes to last commit?


I accidently deleted source directory.. I thought I was deleting another directory. But I have last commit that is where I need to revert back.

I have two branches:

master
dev1

On dev1:

git add .
git commit -m 'commit message'

Then:

git checkout master
git merge dev1

Then I accidently deleted whole repository.

Then I hard reseted to last commit and I see it shows that all correct changes were made. But when I got to my directory it is old directory (I copied old one, but it is not being deleted from here). What Should I do?


Solution

  • If you removed the whole repository, you'll have to get it back from a backup (or reconstruct it from any other repositories you pulled from, or pushed to). There isn't anything for git to work on anymore.