Zezhou Li
Zezhou Li

Reputation: 107

Can I get back deleted files after using git rebase?

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?

Upvotes: 2

Views: 1957

Answers (1)

Harald Nordgren
Harald Nordgren

Reputation: 12409

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.

Upvotes: 6

Related Questions