Changing the default branch in GITHUB SETTING
Here are a few ways to rename the main branch in Git:
1. Rename the local branch:
git branch -m main new-main-branch
This renames your local main branch to new-main-branch
.
2. Push the renamed branch to remote:
git push origin new-main-branch --set-upstream
This pushes the renamed branch to the remote origin and sets it to track the new name.
3. Delete the old remote branch:
git push origin --delete main
Remove the old main branch name from the remote.
4. Change the default branch on remote:
On GitHub or your Git host, change the default branch to point to the new name.
5. Update local references:
git remote set-head origin -a
This updates your local repo to pull from the new default branch.
6. Clean up old references:
git remote prune origin
Prunes stale remote tracking branches.
That's the basic flow - rename locally, push new branch as default, delete old branch name, and update remote references. Just make sure any collaborators are aware of the change.