Accidentally deleted my github portfolio, please help

I don’t even know if there’s anything I can do at this point. My portfolio was hosted on github pages. I have a new project that I was going to add, and instead of cloning the portfolio repo, adding the files to it, I pointed the local project to the portfolios repo with git add remote origin URL, added the files, commited, then pushed to the repo.

It deleted every single file in the portfolio repo, and added the project’s files in it’s place. At least the last two years of portfolio building deleted. I don’t know what to do.

I tried git -revert SHA, but it just deleted the projects files from the repository, it didn’t bring my portfolio back.

Also, my entire commit history is gone besides the one where I pushed the project, and reverted it. Is there any way to get my projects/portfolio back?

Any advice would be greatly appreciated.

Have you force pushed the changes into the wrong repo?
How did your history got deleted? did you delete .git directory?
If git log does not contain previous commits because of a rebase or something, but it is still the same git local repo, you can git reflog to search for basically anything you did.
You may find the latest sha that may be a good commit having the things you want.
You can than git reset SHA

1 Like

Hey, @filipesperandio, that’s strange. I came here to view this. I flagged it for deletion soon after, but told the mods they can keep it up so that people in the future, if facing the same problem, may have some advice to follow. Anyway, I must have clicked on this thread the moment you started typing, because I saw you down at the bottom writing an answer, lol.

I appreciate your reply, and if I face similar actions with git in the future(which I hope doesn’t happen), I will surely follow your advice.

P.S. In case anyone is reading this, take heed of this: do not point a local project to a repository on github(git remote add origin https://github.com/your_username/your_repo.git), and expect it to just add your files to the repository. It will replace everything in the repository. I feel like I should have known this. :sweat_smile: