rename master branch code example
Example 1: git rename branch
git branch -m <oldname> <newname>
git branch -m <newname>
git branch -M <newname>
Example 2: rename branch to main
$ git branch -m master main
or create a new one
$ git checkout -b main
Example 3: rename branch git
git branch -m <new_name>
Example 4: git rename branch
git branch –m old-name new-name
git push origin :old-name new-name
git push origin –u new-name
Example 5: rename branch to main
$ git push -u origin main
Example 6: rename branch to main
$ git push origin --delete master