I have two branches on git - master and main. I wanted to push all my work from the main to the master branch. What I did instead was pushing all my work from the master branch to the main branch. Now all my work from the main branch is gone. I cannot just access a past commit from main because all the commits got replaced from the commits of the master branch.
How can I revert this step to get my old main branch back?
Git commands I used for the mistake
git checkout master
git branch main master -f
git checkout main
git push origin main -f
What I wanted to do instead (I guess)
git checkout main
git branch master main -f
git checkout master
git push origin master -f