Github files got overwritten


I’m a student and due to Coronavirus had to upload some simple scripts into my Github. So yesterday I had around 5 folders that had files in “skriptimine” repository. All that previous work was done at school. So I wanted to upload a new script to Github and for some reason it overwrote my repository (all my previous scripts got deleted). 

git add yl1

git commit -m “Hüpotenuus” #It shows "Praks5"on the image, I did git commit --amend command and pushed the upload again. Not sure why.
git push -uf skriptimine master #I got some sort of error, after next command didn’t get the error anymore
git remote add skriptimine
git push -uf skriptimine master #yl1 got uploaded and old scripts got deleted. Searching for a solution if I can recover them.

After these commands the new yl1 file got uploaded and previous files got deleted. Can I somehow recover the deleted files? Thank you.

I assume what happened is that you didn’t have the history of the work done at school on your home machine. When you use “-f” with “git push” it will overwrite any conflicting history, which is why the other work got overwritten. It is highly recommended not to use -f unless you have double checked it is necessary and the state and history are correct.

In this situation I see only one thing you can do yourself: Get to the repository you used at school (or get a copy), and recover the work from there. Either merge the branches, or copy the files and make a new commit with them.

You could also try asking Github support if they have a backup, but I have no idea about the chances.

Thank you so much for the reply!

Hello, if your data was overwritten, you can just use a data recovery tool to recover it. I have used Bitwar Data Recovery, and I think this tool is safe and efficient, you can also have a try if necessary.