2

Today I was going to upload my local project files to Github using shell, but unfortunately deleted the local files after calling "git rebase" command. How can I get the deleted files back?

Zezhou Li
  • 107
  • 1
  • 2
  • 12

1 Answers1

6

Check git reflog for a revision history for your repo, something like:

b3f2a61 HEAD@{0}: commit (amend): Adding some more files
ba90657 HEAD@{1}: rebase: Message
3dcbd41 HEAD@{2}: commit: Adding some files

You can resore the repo to a previous state by using the commit ID in the first column like

git reset --hard <ID>

Be careful that this wipes everything that was committed to the repository after the restore point. You may want to back that up separately before doing a hard reset.

Harald Nordgren
  • 11,693
  • 6
  • 41
  • 65