1 Overview
After October 1, 2020,Github
The default branch of all new warehouses will be transferred frommaster
Change tomain
This leads to some old warehouse main branchesmaster
, the main branch of the new warehouse ismain
This sometimes brings some trouble, so here is a scheme to replace the old warehousemaster
Branch migration tomain
Branch.
2 specific steps
Four steps:
- Clone original warehouse
- Create and push
main
branch - Modify default branch
- delete
master
branch
2.1 cloning
First, clone a copy of the original warehouse to operate locally:
git clone xxxxxxx.git
2.2 create and pushmain
Create and switch tomain
:
git checkout -b main
Pushmain
:
git push origin main
2.3 modify default branch
This step requiresGithub
Enter the warehouse settings and click the branch option:
Change the default branch tomain
, and click the on the rightUpdate
, clickUpdate
There will be a prompt after that, which may affectPR
And cloning:
After confirming the modification, you can see that the default branch has been modified tomain
:
2.4 deletionmaster
Delete localmaster
:
git branch -d master
Delete remotemaster
:
git push origin :master
In this way, even if you successfully migrate tomain
It’s branching.
2.5 testing
Submit after making some modifications in the warehouse:
git add -A
git commit -m "test main branch"
git push origin main
Can seeGithub
There will be corresponding updates on.