HOW CODEBERG COMMUNITY HELPED ME TO RESTORE MY REPO

HOW CODEBERG COMMUNITY HELPED ME TO RESTORE MY REPO

Today, I’ve accidentally deleted local .git index folder of my blog repository, because of this I was not able to submit new content.
Tried to restore files by File Scavenger, but it was too late because I was in the middle of active file operations and .git folder was erased without any chance of returning it back to drive.

I’ve tried to recreate index by means of:

git init

But Git-Bash-console threw me an error:

error: src refspec main does not match any
error: failed to push some refs to 'origin'

Solution was kindly provided by @tastytea:pixie.town from Codeberg chat at Matrix channel.

General overview of the solution:

  • render static pages again [in my case it was plain execution of Hugo framework]
  • move rendered static blog files [all files in public folder] to somewhere else
  • clone blog from Codeberg repo into public folder [after cloning public folder will contain hidden .git folder]
  • and finally copy all files from previously created backup over the cloned ones

Linux commands suggested by TastyTea:

mv PUBLIC-FOLDER-OF-MY-BLOG MY-PUBLIC-FOLDER_BACKUP
git clone git@codeberg.org:MY_BLOG_ADDRESS/pages.git  PUBLIC-FOLDER-OF-MY-BLOG
cp -a MY-PUBLIC-FOLDER_BACKUP/* PUBLIC-FOLDER-OF-MY-BLOG/
git add -A
git -am "commit-after-deletion-of-git-folder"
git push origin main

SOME NOTES:

In my case it was Windows 7. So for moving and copying stuff I’ve used fast’n’trusty Far Manager .



Git clone command was executed in Git-Bash console . Before execution system will asks you a password to your initially generated SSH keys.



This concludes a little bring-your-site-back tutorial. Hope that you won’t run into such situation and nobody will need these instructions.