GitHub安装(Windows)

Git安装:

打开Windows PowerShell,输入命令行如下:

winget install --id Git.Git -e --source winget

输入命令行如下:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\a-xiaobodou> winget
Windows 程序包管理器 v1.3.2691
版权所有 (C) Microsoft Corporation。保留所有权利。

WinGet 命令行实用工具可从命令行安装应用程序和其他程序包。

使用情况: winget [<命令>] [<选项>]

下列命令有效:
  install    安装给定的程序包
  show       显示包的相关信息
  source     管理程序包的来源
  search     查找并显示程序包的基本信息
  list       显示已安装的程序包
  upgrade    显示并执行可用升级
  uninstall  卸载给定的程序包
  hash       哈希安装程序的帮助程序
  validate   验证清单文件
  settings   打开设置或设置管理员设置
  features   显示实验性功能的状态
  export     导出已安装程序包的列表
  import     安装文件中的所有程序包

如需特定命令的更多详细信息,请向其传递帮助参数。 [-?]

下列选项可用:
  -v,--version  显示工具的版本
  --info        显示工具的常规信息

可在此找到更多帮助: https://aka.ms/winget-command-help
PS C:\Users\a-xiaobodou> winget install --id Git.Git -e --source winget
已找到 Git [Git.Git] 版本 2.38.0
此应用程序由其所有者授权给你。
Microsoft 对第三方程序包概不负责,也不向第三方程序包授予任何许可证。
Downloading https://github.com/git-for-windows/git/releases/download/v2.38.0.windows.1/Git-2.38.0-64-bit.exe
  ██████████████████████████████  50.8 MB / 50.8 MB
已成功验证安装程序哈希
正在启动程序包安装...
已成功安装
PS C:\Users\a-xiaobodou>

截图:

GitHub安装(Windows)_第1张图片

弹出Git安装程序,自行安装,顺利完成。 

Git设置:

用户名和电子邮件地址设置:

打开“Git Bash”,输入命令行:

git config --global user.name "your_name"
git config --global user.email "your_email_id"

输入命令行的时候,不需要输入双引号。

生成SSH密钥的输入命令行:

ssh-keygen -t rsa -C "[email protected](host name)" 

输入命令行的时候不需要输入双引号。

保存目标路径:密码短语设置,确认密码,都按下三次Enter键。

在此过程中,将生成以下文件

C:\Users\%USERNAME%\.ssh\id_rsa - 密钥(未向任何人显示)
C:\Users\%USERNAME%\.ssh\id_rsa.pub - 公钥(在GitLab等注册)
C:\Users\%USERNAME%\.ssh\config - 通过服务设置SSH密钥
 

GitHub安装(Windows)_第2张图片

 

在Github上,右上角点击头像,弹出拉下菜单,点击“Settings”,点击“SSH and GPG Key”,点击绿色标签“New SSH Key”。

通过记事本打开id_rsa.pub文件,复制,粘贴到GitHub里面New SSH Key。

为了验证是否成功,在git bash下输入命令行:

ssh -T [email protected]

输入命令行如下:

FAREAST+a-xiaobodou@DESKTOP-3P89ER1 MINGW64 ~
$ git config --global use.name "douxiaobo"

FAREAST+a-xiaobodou@DESKTOP-3P89ER1 MINGW64 ~
$ git config --global user.name "douxiaobo"

FAREAST+a-xiaobodou@DESKTOP-3P89ER1 MINGW64 ~
$ git config --global user.email "[email protected]"

FAREAST+a-xiaobodou@DESKTOP-3P89ER1 MINGW64 ~
$ git config --global user.name douxiaobo

FAREAST+a-xiaobodou@DESKTOP-3P89ER1 MINGW64 ~
$ git config --global user.email [email protected]

FAREAST+a-xiaobodou@DESKTOP-3P89ER1 MINGW64 ~
$ cd~
bash: cd~: command not found

FAREAST+a-xiaobodou@DESKTOP-3P89ER1 MINGW64 ~
$ ssh-keygen -t ras -C [email protected] -b 4096
unknown key type ras

FAREAST+a-xiaobodou@DESKTOP-3P89ER1 MINGW64 ~
$ ssh-keygen -t rsa -C [email protected]
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/a-xiaobodou/.ssh/id_rsa):
Created directory '/c/Users/a-xiaobodou/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/a-xiaobodou/.ssh/id_rsa
Your public key has been saved in /c/Users/a-xiaobodou/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:Mga6AOy3yodv2X3lQcWK4rI5NQOOLGlpM9QjtRniouk [email protected]
The key's randomart image is:
+---[RSA 3072]----+
|            .    |
|.. o         o   |
|o.+ =     . o    |
|++ * o . . o     |
|=o*.+ * S .      |
|oX.+.+ B   o     |
|+ *.o * o o .    |
|.E.+ = . . .     |
| o+.  . .        |
+----[SHA256]-----+

FAREAST+a-xiaobodou@DESKTOP-3P89ER1 MINGW64 ~
$ ^C

FAREAST+a-xiaobodou@DESKTOP-3P89ER1 MINGW64 ~
$ ssh -T [email protected]
ssh: connect to host icloud.com port 22: Connection timed out

FAREAST+a-xiaobodou@DESKTOP-3P89ER1 MINGW64 ~
$ ssh -T [email protected]
ssh: connect to host icloud.com port 22: Connection timed out

FAREAST+a-xiaobodou@DESKTOP-3P89ER1 MINGW64 ~
$ ssh -T [email protected]
 ssh: connect to host githu.com port 22: Connection timed out

FAREAST+a-xiaobodou@DESKTOP-3P89ER1 MINGW64 ~
$ ssh -T [email protected]
The authenticity of host 'github.com (20.205.243.166)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
Hi douxiaobo! You've successfully authenticated, but GitHub does not provide shell access.

FAREAST+a-xiaobodou@DESKTOP-3P89ER1 MINGW64 ~
$

截图如下:GitHub安装(Windows)_第3张图片

 

在Visual Studio Code中使用Git和GitHub

1、在Visual Studio Code中设置Git

点击"File"--"Preferences"--"Settings" 

GitHub安装(Windows)_第4张图片

搜索"gitpath",点击"Edit in settings.json"

GitHub安装(Windows)_第5张图片

 之前:GitHub安装(Windows)_第6张图片

复制文件地址:

GitHub安装(Windows)_第7张图片

 

粘贴之后:

GitHub安装(Windows)_第8张图片 

修改地址:四个地方多加\字符

GitHub安装(Windows)_第9张图片

保存之后,重启Visual Studio Code即可。 

 

你可能感兴趣的:(Github,github)