Assume the current main branch is named master and you you created a new branch with the name main that should be the new main branch.
Also assume, that you have forked the main repo and you want to switch to this new main branch.
Fetch the new branch information from upstream
git fetch upstream
Checkout the new main branch and remove the old one
git checkout -b main upstream/main && git push -u origin main && git branch -d master
Change the main branch in the GIT repo online. Remove the old master branch in the repo
git push origin :master
Synchronize the data
git remote prune origin upstream