These commands helped me solve the issue:
cd repo
mv .git ../repo.git # renaming just for clarity
cd ..
rm -fr repo
cd repo.git
git config --bool core.bare true
What are we doing here? Replace the contents of repo with the contents of repo/.git, then tell the repository that it is now a bare repository.