Steps for git to submit local code to github or gitee

1. In the project directory, right click git bash here
2. git init, initialize the git management project
3. 在github或gitee上创建一个远程仓库,远程仓库要空仓库,什么东西都没有,否则会有合并问题。git remote add origin https address
First, you need to git pull origin master, otherwise you will get an error when submitting the code
4. git status Check the files that have not been submitted to the temporary storage area. Some files do not need git management, so touch .gitignore, you can add files that do not need git management in it
5. git add. Submit all files to the staging area
6. git commit -m "init" The double quotation marks are an explanation of this submission, and the files in the temporary storage area are submitted to the local repository
7. Since the local repository has established a relationship with the remote repository, git push -u origin master. Then enter the corresponding account password of github or gitee, and the local code will be successfully submitted to the remote warehouse.

When I watched the video tutorial, I found that the teacher used the -u parameter and did not explain it. I searched for the usage of -u. After adding the parameter -u, you can directly use git push instead of git push origin master.

The README.md file is generated and edited online, but it is not included in the local code file, so the online and offline are not compatible.
Combine the online and offline code git pull --rebase origin master
This will appear when you create a new project, because there is a file in the warehouse that we don’t have. After all the merge, you can submit it, and git and local The code has established a connection

8, git checkout switch branch command
For example, my project is tensquare_parent, you can name the project xxx, write tensquare_parent in the path, and submit all the content in the tensquare_parent directory when submitting
How to choose an open source license https://blog.csdn.net/qq_28537277/article/details/95172022
Some problems encountered:

1. The README.md file is generated and edited online, but it is not included in the local code file, so the online and offline are not compatible.
Combine online and offline code git pull --rebase origin master

2. After installing Git, first set the user name and email address, because every Git submission will use the user information
git config --global user.name “zhong”
git config --global user.email “[email protected] "
Git config user.name view user name
git config user.email view mailbox

3、解决:Gitlab上出现“You won’t be able to pull or push project code via SSH until you add an SSH key to you”
https://blog.csdn.net/gufenchen/article/details/95663284

Insert picture description here
4. Forcibly let the local branch cover the remote branch (team development and use will be life-threatening)
git push origin master -f

5. Two ways to create a branch
git branch branch name git checkout branch name
Create and switch to the current branch git checkout-b branch name

6. Sometimes when git push, because the remote code has changed, conflicts will occur. At this time, git pull is required, and then it will enter the command line window mode. Just need i, esc, :eq to exit, don’t panic

Guess you like

Origin blog.csdn.net/qq_44752641/article/details/108485753