You can change the permissions of the file (CHMOD) to remove write access for the owner (like 0444).
BUT, this means you can NEVER make ANY changes to this file EVER AGAIN. Want to make it editable again? You can’t. Want to make changes? You can’t. Want to delete it on purpose? You can’t.
There isn’t really a way to protect a file against accidental changes, but still allow intentional ones.
It’s your site, but I would personally just make sure I have a backup of the files and just be careful when making changes to the site.