So yesterday I made a push of my code to a Bitbucket repo. After realizing this was the incorrect repo to push to, I did a git reset --hard
to remove the commit. However, after doing that, I noticed that my local files were deleted. Sadly, I did not create a backup of those recent files. Yes, I do have a much older copy of those files.
I've explored the .git
folder and see that the commit prior to my git reset --hard
is there. However, I am not sure how to get to the files within that commit. The .git
folder has all of the appropriate folders: hooks, info, logs, objects, refs, as well as the main directory files (ie. HEAD, description, etc).
If I do a git fsck --full
, I get a few errors:
error: HEAD: invalid reflog entry a5564cddeffd7673cf418955f01bec5d4003f630
error: HEAD: invalid reflog entry a5564cddeffd7673cf418955f01bec5d4003f630
error: refs/heads/master: invalid reflog entry a5564cddeffd7673cf418955f01bec5d4 003f630
error: refs/heads/master: invalid reflog entry a5564cddeffd7673cf418955f01bec5d4 003f630
dangling commit 141d684c3fd2d0da2d6df9844bfeea9e976c9b32
I looked in .git/logs/refs/heads/master
to identify the commit I need.
The line with the one I want is this one:
452f1923ac02bfb1c0930ecfb39d7234db9b6f0f a5564cddeffd7673cf418955f01bec5d4003f630 [username] <email> 1594581184 -0500 commit: Initial commit
Is it even possible to get my files back? And if so, how can I do that? Thank you for any guidance you can provide! I normally back up my files, so this is uncharted territory for me.