Hoping someone can help with this. I’ll freely admit I’m no Git expert so there might be some false assumptions in the following.
We use Git for source control and the SourceTree GUI as a front end. Yesterday, while I was working, our corporate antivirus software (Sentinal One) identified Source Tree as a potential threat and blocked it. Subsequently it popped up a toaster notification saying that it had fixed it. I don’t know exactly what it did but it left my local Git repo in a corrupted state. A bunch of source files are missing and the .git folder was missing several necessary files (Head, Fetch_Head, Orig_Head, config and index). The repo is no longer available in Source tree and a “Git Branch” was reporting that it wasn’t a valid Git repository. I’ve taken a copy of my corrupted repo so at least I know I can get back to this point if things I try make things worse.
On the off chance I tried copying a HEAD file from an unrelated repo and this seemed to fix the Git Branch issue. It now reports as a valid directory and reports some of my branches. What it doesn’t report is two branches which I was only holding locally (I didn’t want to push them to remote until they were production ready) which represent a significant amount of work. I could just reclone from the central repository but I’ll lose those branches as they were never pushed.
I’ve run a Git reflog against the directory and I can see various actions I took moving to and from those branches so it looks like the log is still complete. On the off chance I tried a git checkout of the feature but this reports that it “did not match and file(s) known to Git”. Finally, I tried a git fsck and that reports an error: refs/heads/feature/myfeature invalid reflog entry followed by a bunch of missing blobs and dangling commits and trees. So my local feature is still known about in some form.
My best guess is that the actual source is still held somewhere in the repository but the sudden blocking of source tree has caused the meta data to become corrupted. I’ve found some posts that explain how to automatically prune the source data so that it matches the meta data but I think I want the opposite. I want to rebuild the meta data from the source data.
Is that possible? Is there anything anyone can suggest that might help me recover. (Apologies for the length of the post but I wanted to put out as much info as I could)