BACK UP YOUR REPO BEFORE DOING ANYTHING LIKE THIS!!
git checkout --orphan future-main
git add -A # Add all files and commit them
git commit -m "Initial commit"
git branch -D main # Deletes the main branch
git branch -m main # Rename the current branch to main
git push -f origin main # Force push main branch to github
git gc --aggressive --prune=all # remove the old files
As one single copy and paste command:
git checkout --orphan future-main && git add -A && git commit -m "Initial commit" && git branch -D main && git branch -m main && git push -f origin main && git gc --aggressive --prune=all
Works well with git submodules too. From: https://stackoverflow.com/a/13102849/1253966