The connection and use of Git and Github

The connection and use of Git and Github

 

Continue below, use git to upload the project to GitHub

First of all, you must have a GitHub account. It goes without saying. If you don't have one, register first. Address: https://github.com 

If there is no warehouse, create a new warehouse first

Fill in the new warehouse name and remarks. Click Create to finish.

 

After the creation is completed, the following interface will be displayed. Put it aside first. will be used later

 

 

Because the transmission between the local Git repository and the GitHub repository is encrypted through SSH, GitHub needs to identify whether it is you who pushed. As long as GitHub knows your public key, it can confirm that only you can push, so you need to configure the ssh key.

1. Create an SSH Key.

In the user's home directory (C:\Users\Administrator), check whether there is a .ssh file. If so, check whether there are these two files under the id_rsafile id_rsa.pub. If there is already, you can go directly to the next step. If not, open Git Bash, enter the command, create an SSH Key

1

$ ssh-keygen -t rsa -C "[email protected]" //123 是你自己注册GitHub的邮箱

Just go back

When the above picture appears, it means that the creation is successful, and then go to the user's home directory to find the .sshfolder, there are id_rsatwo id_rsa.pubfiles in it, and these two are the key pair of the SSH Key, which is the private key id_rsaand cannot be leaked. id_rsa.pubpublic.

 

2. Next, go to GitHub, open the "Account settings"--"SSH Keys" page, then click "Add SSH Key", fill in the Title (freely write), and paste  id_rsa.pubthe entire contents of the file in the Key text box.

Click "Add Key", you should see the keys that have been added, you can add multiple keys

 

3. To verify whether it is successful, enter the following command in git bash

1

$ ssh -T [email protected]

If you set it for the first time, the following interface will appear, enter yes to agree

4. Start setting username and email below, because github will record them every time they commit

1

2

$ git config --global user.name  "name"//你的GitHub登陆名

$ git config --global user.email "[email protected]"//你的GitHub注册邮箱

5. The next step is to upload the local warehouse to github. A new warehouse was built on GitHub before, and the page to jump to, just operate according to the above.

 

1

2

$ git remote add origin [email protected]:flora0103/example.git    //关联一个远程库命令, [email protected]:flora0103/example.git   这个是自己远程库

git push -u origin master    //关联后,第一次推送master分支的所有内容命令,此后,每次本地提交后,就可以使用命令g

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325726634&siteId=291194637