I had the unfortunate incident of getting a BSOD while switching my Git branch that I hadn't pushed to my remote repository. After the computer rebooted and logged back in, I found out that my workspace is corrupted. Here are the symptoms:
Can someone help me get the workspace to a working state again or recover some of the files in the branch or stash?
I am having the same issue with one of my local repositories this morning. I have never seen this in all the years I've been using Git. I have been using this particular repo for 4 months but now it tells me it's not a git repository when all the directories and files (including .git) are there. I have had some issues with my machine (Windows 7) shutting down at night for no apparent reason which could have caused some corruption since I tend to leave Intellij open all the time. My git version is 1.9.4. I tried "git init" to reinitialize the local repository, but it didn't help. I updated Git to version 1.9.5, no help. The local repo still has my local settings (git config --local -l). Luckily I commit and push my branches often so recovery was as easy as re-cloning, but it still leaves me scratching. I renamed my existing local repo to something else then re-cloned the remote repository and all is good now with the new clone (the old one is still dead).
With a lot of help from my former colleague, I figured out how to recover from this. You probably want to do this as the last resort because you'll probably lose some information and it is possible that this might not work because of corruption.
Let's name the corrupted workspace is "corruptWorkspace" and the workspace to be fixed on is "fixWorkspace" First step you need to do is create a new workspace to do your recovery and copy the object and refs:
From here you can recover a branch/commit.
This command should be readable and show the last commit changes
After confirming that the branch looks ok, try to check it out
Then you can reset the branch
At this point you have the latest committed version of your branch. The next step is to recover the stash file.
List the files that are in the stash for you to recover, from here you can get the location and file that were stashed to be used for restoring the file
Recover the stashed files
After you've done the above command for all your stashed files, you have finished getting your branch and your stashed file. if the config file is not corrupted, you might even be able to copy the "origin" definition and push your changes.
Good Luck
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