Git- upload local projects to github

Foreword: Because I just finished the ssm project and wanted to upload the project to github, I started a new learning journey. This article will record the successful process last night and make it easy to read it later.
(This tutorial is also suitable for novices who have not yet started learning Git like me)

1. First have a github account and Git

Create a github account

If you want to upload your local project to github for collaborative development by multiple people, we need to register a git account before using github as a remote warehouse.

1. Open the registration link: https://github.com/join
2. Fill in the relevant information
3. Open the registered mailbox, open the received verification email, and click to complete the account verification
4. Click "Sign in" in the upper right corner to enter the Registered registered email and password, log in to github

Git download tutorial

Installation reference link: https://blog.csdn.net/weixin_44325444/article/details/107034337
Baidu cloud disk link: https://pan.baidu.com/s/1EwuqUEPJsMN4twCCSBA03g
Extraction code: e55i
(because the official website download is slow, Upload the compressed package to Baidu cloud disk for everyone to download, you can also use Thunder to download)

2. Create a remote warehouse

With a github account, we can then create a remote warehouse through the account to store the project code we uploaded.

Log in to github account

Click the + icon in the upper right corner and choose to create a new warehouse

Insert picture description here

As shown in the figure, fill in the information of the warehouse we want to build

Insert picture description here

At this time we can see the warehouse we just created

Insert picture description here

3. Push the local warehouse to the remote warehouse

1. First, we need to create a local warehouse;
we need to find the working directory of the local project first, right-click git bash here to
Insert picture description here
initialize the local warehouse

Insert picture description here
At this time, we will see that there is an extra .git folder in the working directory.
Insert picture description here
Then, we use the git add * command and the git commit command to add the files in the workspace to the temporary storage area and submit them to the local warehouse
Insert picture description here
Insert picture description here
2. The second step, We need to connect to the remote warehouse created before;
first, we first obtain the URL of the remote warehouse created before:
Insert picture description here
Next, connect to the remote warehouse through the git remote command:
Insert picture description here
you can view the name of the remote warehouse through git remote -v:
Insert picture description here
3. Next , We can upload our local code to the github remote warehouse.
Use the git push command.
Insert picture description here
Note: If a failed to push some refs to git error occurs at this time,
this is generally because the README.md file in github is not in the local code directory. At this time We can use the ** git pull --rebase origin master ** command to merge the code, and then we can see that there are more README.md files in the local code base.
The following problems may occur after executing the above code.
Note: If git reports fatal: Updating an unborn branch with changes added to the index at this time. The
Insert picture description here
reason for the error is that the files submitted to the repository have not been submitted to the branch and are still Temporary area, so execute the
git commit -m'xx' command.
At this time, execute the
git push -u origin master command
.

After waiting for the transfer to complete, we can see that the project file we uploaded appears in the remote warehouse of github:
Insert picture description here

That's it! ! ! ! ! ! Finished with flowers! !


Continuously updating...
Article reference learning address: https://www.jianshu.com/p/0a94c0a24270

Guess you like

Origin blog.csdn.net/weixin_44325444/article/details/107033808