The "nuke and pave" option is not necessarily your only option, but it may be your best one. A "bad tree object" is an unusual error and suggests that parts of your repository may be corrupted (by disk failure, or rogue process / malware / whatever overwriting your files, or attempting to store a Git repository in a dropbox folder, or who knows what). If you are going to nuke it, you might want to back it up first just in case, though.
If you're doing a git push
with no options, that suggests that you have a separate copy of the repository (slightly out of date, perhaps) with most of the code in it, probably on a different machine. That separate copy elsewhere may still be good. You could check that, perhaps by cloning it to a fresh location, and then update the fresh clone with new commits made from whatever you can salvage from the damaged repository, and push those so that the new commits are added to that other repository on the other machine. Then you can really be comfortable with nuke-and-pave since you have two good copies: one in your fresh clone (the third Git in this scenario), and one on the other machine (the second Git here—the first Git is your corrupted repository).
It's also worth doing some background investigation into what corrupted the repository in the first place, since that might still be going on.
As an aside, even if the tree object 4218a5a380d8b6cbc7f461c22cb48ed66a92c850
exists as a loose object, it won't be in a file named 4218a5a380d8b6cbc7f461c22cb48ed66a92c850
. It will be in a directory named 42
stored as a file named 18a5a380d8b6cbc7f461c22cb48ed66a92c850
.
If the object has been packed, it won't be around as a separate file at all, but rather as a packed object in some pack file (whose name is not predictable).