git installation and remote connection to github (4) - remove master and use main

Source:
Disclaimer: If I violate anyone's rights, please contact me and I will delete it.
Welcome experts to spray me

I used the master branch to upload files before, but I was asked to compare & pullrequest. Where can the master merge? ! Later, I found out that there was already a branch of main. From then on, the master was just a little brother. The most terrible thing was that the master merged with the main. !

Related operations without merging
Insert picture description here

Either submit directly with the main branch, or create a sub-branch dev and merge into the main after submission
main branch commit

1.git checkout -b main Create the main branch and enter:
Insert picture description here
2.git branch -D master delete the local master branch
First use git branch to see which branches are there:
Insert picture description here
After deleting:
Insert picture description here

3.git push origin --delete master delete the master branch on the github project:
Insert picture description here
Insert picture description here
after deletion:
Insert picture description here
4.git push -u origin main: push code

Insert picture description here

Updates were rejected because the tip of your current branch is behind错误:

You should git pull first: git pull origin main
Insert picture description here
has version conflict again,
then use
git pull origin main --allow-unrelated-histories
Insert picture description here
to execute git push origin main
Insert picture description here
successfully! ! !

Guess you like

Origin blog.csdn.net/qq_45531729/article/details/111668830