I am sorry this happened to you, man, but seriously, such an amateur mistake. I am a software developer and for the last 10 years, after every meaningful code change I push the code up to Github. I also connect all my machines to a Time Machine from day one. This is not an M1 issue either. I had expanding battery issues on 3 machines in the last decade on Intel Macs. Technology in general is just not 100% reliable. Back everything up. Always.