I had some files on my project which rebase deleted. I did not commit anything. I lost some important files, how can I recover them?
In this case, you can restore the file using either git checkout or git reflog . You can find the hash-ID of the previous commit from the command: git log . In case you don't have the hash ID, you can use the command git reflog .
You can restore a deleted file from a Git repository using the git checkout command. If you do not know when a file was last deleted, you can use git rev-list to find the checksum of the commit in which that file was deleted. Then, you can check out that commit.
git reflog
works wonders in such situations: simply use git reflog
and note few recent commits that were active. Then use git checkout commit_id
to checkout to any particular commit. Most likely, you need previous commit (current one is one you have screwed up).
Also, if you rebase was not committed yet, you can abort it with git rebase --abort
.
If it was committed, you can simply kill last commit with git reset --hard HEAD~
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With