How do you rename a branch, including the default branch?
BeginnerConceptCommits, branches and tags
Answer
Rename locally with git branch -m, push the new name, and delete the old one remotely. For the default branch also change it in the hosting platform settings and tell everyone to update their local tracking.
git branch -m master main
git push -u origin main
git push origin --delete master
git remote set-head origin -a
More on Commits, branches and tags
How do you write a good commit message?BeginnerWhat is the difference between `git add .`, `git add -A` and `git add -u`?BeginnerHow do you commit only part of the changes in a file?BeginnerHow do you change the last commit message or add a forgotten file?BeginnerWhat is the difference between `git switch`, `git restore` and `git checkout`?BeginnerWhat is the difference between lightweight and annotated tags?Beginner