bad sha1 files handling

First since the issue is on the server, check if you don't have any clone which would not show the same issue: you could make a local bare repo clone out of that clone, and replace your "user@server:/var/git/REPOSITORY.git" with a copy of said bare repo.

Second, on the server:
Simply make a copy of user@server:/var/git/REPOSITORY.git in user@server:/var/git/REPOSITORY2.git, remove those '_' files and see if the error persists.
My guess is: the missing commit and tree will still be there.
That means you need to look for those in a clone in order to restore them, as I recommend in "How to diagnose and fix git fatal: unable to read tree".
See more at "How to fix corrupted git repository?".