Restore deleted files

101 Views Asked by At

I had a lot of files in directory public/uploads/. Before commit I typed git rm -- public/uploads/* and then git commit -a -m "upload" and then git push origin master. In previous commit photos are not present. Now I want to restore them back from git to server. How can I do that?

1

There are 1 best solutions below

3
On BEST ANSWER

You cannot recover them if they were never added or committed.

Let's say the hash of the commit where you deleted them is abc123. If you want to undo the whole commit, simply do git revert abc123. If there were other parts of the commit you want to keep, do:

git revert abc123 --no-commit
git reset
git add public/uploads/
git commit

Then the files will be back in the repository.