Git installation under Windows, git and github connection, TortoiseGit configuration record

1. Git installation:
1.1. Installation method:
After downloading from the official websiteInstall all the way by default, always choose the next stepfinish installation.
See the specific process: Git download and install blogfirst part

1.2. Configure username and email: After
git is installed, go to GitHub to register an account, and then:

$ git config --global user.name "username"  //( "username"是自己的github账户名)
$ git config --global user.email "[email protected]"  //("[email protected]"是注册github账号时用的邮箱)

2. Connect git and github:
2.1. First configure the key (in order to upload files to GitHub, you no longer need to enter a password and other operations):

$ ssh-keygen -t rsa -C "[email protected]" // 双引号里面是你的github邮箱。

thenEnter all the way (three times to enter), just use the default valueSince this Key is not used for military purposes, there is no need to set a password.

2.2. Save the key to github:
Just put it in the personal settings -> SSHKey (take any name).
Detailed process: upload the GIT local warehouse to the GitHub remote warehouse

Note: The generated key matches the computer. Therefore, when an account is added to github on both the company's computer and the home computer, you need to put the generated keys in github. For details of this part, see:Detailed explanation of key .

2.3. Operations that can be performed at this time:
A: Connect local existing warehouses and github hollow warehouses:
First create a warehouse on github, The prompt is as follows after completion: the
Insert picture description here
prompt can use the command in the figure herePush the local warehouse to the remote warehouse, The command is explained as follows:

#git remote add [shortname] [url]  // shortname:你定义远程仓库别名,一般默认为origin。 url:远程仓库地址
git remote add origin [email protected]:ZhiyuZhang1994/-firstgitrepo.git // 建立本地仓与远程仓的连接

git push -u origin master # origin为远程仓别名,将本地master仓库push上去

NOTE: The local name for the warehouse git initname when the folder of the remote warehouse name can be different, but consistent, then intuitively easy to understand.
Note: The SSH connection must be selected for upload and download, otherwise the account password must be verified every time the HTTP connection is made.

B: Pull the existing code warehouse
in github from github: call git clone in the folder to directly pull the existing warehouse in github, the code is as follows:

git clone [email protected]:ZhiyuZhang1994/-firstgitrepo.git // 切记选SSH的连接,HTTP连接需要每次验证用户名与密码

When the cloned warehouse is modified and then pushed to the remote warehouse, there is no need to git remote add origin 。。。connect to the remote warehouse again, and git clonewill automatically change the github warehouse address to origin.

Note: When you use Git's clone or push command to connect to GitHub for the first time, you will get a warning:

The authenticity of host 'github.com (xx.xx.xx.xx)' can't be established.
RSA key fingerprint is xx.xx.xx.xx.xx.
Are you sure you want to continue connecting (yes/no)?

This is because Git uses SSH connection, and when SSH connection verifies the key of the GitHub server for the first time, you need to confirm whether the fingerprint information of the GitHub Key really comes from the GitHub server, and just enter yes and press Enter.
Git will output a warning telling you that the GitHub Key has been added to a trust list on this machine:

Warning: Permanently added 'github.com' (RSA) to the list of known hosts.

This warning will only appear once, and there will be no warnings for subsequent operations.

3. TortoiseGit configuration record:
3.1. Configuration process:
install after downloading. See the blog for the configuration process: TortoiseGit installation and configuration
TortoiseGit also need to configure the key. The process is in the blog, and the generated key can also be placed in github.

3.2, TortoiseGit common problem solving:
sometimes problems occur after configuration no supported authentication methods avaiable,
see the solution: git error Disconnected: No supported authentication methods available solution

to sum up:

1. The generated keys are for computers, so multiple computers of a user need to generate multiple keys.
2. Use SSH to download, convenient and fast.
3. You need to create a remote warehouse before you can associate with a local warehouse. You must associate with a remote warehouse before pushing a local warehouse.
4. The name of the remote warehouse and the local warehouse can be different, but the same is easy to understand and remember.

Guess you like

Origin blog.csdn.net/qq_33726635/article/details/106437643