How can I retrieve crucial git information after a power outage corrupted git files?

Viewed 420

and thank you in advance for any help! I recently made a git commit, and in the middle of the commit, my computer lost power. Upon running git status, I get:

error: object file .git/objects/53/e4ea5d9c33089c5bc20b64b5a24f6b9f9fa62f is empty error: object file .git/objects/53/e4ea5d9c33089c5bc20b64b5a24f6b9f9fa62f is empty fatal: loose object 53e4ea5d9c33089c5bc20b64b5a24f6b9f9fa62f (stored in .git/objects/53/e4ea5d9c33089c5bc20b64b5a24f6b9f9fa62f) is corrupt

This is a big problem, and there are a ton of missing/corrupted git files shown by running git fsck --full. Thankfully it appears that all of my actual files are fine. I did some reading on the subject and I think the simplest solution is to clone the remote repository, then take the .git folder of the remote and move it into my local folder. I tried cloning the remote, but no .git folder was present.

How can I get the .git folder from the remote repository so that I can continue committing using my current local files? I don't care if my local commit history since the last push is deleted, I just need to continue working on my current local files.

Thank you very much! Help is needed because this is a very important repo.

1 Answers

I suggest running git clone <remote URL>. This will create a new directory with the same state as the remote. Then you can copy the local files from your original directory to this new one and continue working from there.

Related