编程知识 cdmana.com

GitHub warehouse master branch to main branch migration guide

1 summary

2020 year 10 month 1 In the future ,Github The default branch of all new warehouses will be changed from master It is amended as follows main, This leads to some old warehouses where the main branch is master, The main branch of the new warehouse is main The problem of , This can sometimes cause some trouble , So here's a solution to take the master Branch to main Branch .

2 Specific steps

The four step :

  • Clone the original warehouse
  • Create and push main Branch
  • Modify the default Branch
  • Delete master Branch

2.1 clone

First clone a copy of the original warehouse to operate locally :

git clone xxxxxxx.git

2.2 Create and push main

Create and switch to main

git checkout -b main

push main

git push origin main

2.3 Modify the default Branch

This step needs to be Github Operation in , Enter the warehouse settings , Click on the branch option :

 Insert picture description here

Change the default branch to main, And click on the right Update, Click on Update There will be a hint that may affect PR And cloning :

 Insert picture description here

After confirming the modification, you can see that the default branch has been modified to main

 Insert picture description here

 Insert picture description here

2.4 Delete master

Delete local master

git branch -d master

Delete remote master

git push origin :master

So even if you successfully migrate to main The branch .

2.5 test

Make some changes in the warehouse and submit it :

git add -A 
git commit -m "test main branch"
git push origin main

You can see Github There will be a corresponding update on .

版权声明
本文为[The cold]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201224223721789W.html

Scroll to Top