『现学现忘』Git基础 — 4、Git下载与安装
阅读原文时间:2022年04月12日阅读:1

目录

进入官方地址下载Git客户端:https://git-scm.com/download/win

国内Git客户端镜像下载地址:[https://npm.taobao.org/mirrors/git-for-windows/](

在下图的位置进行下载。

运行Git安装文件,在桌面点击下面图标。

(1)Step 1 Information(信息)

首先看到的是GUN协议,点击Next

说明:

Please read the following important information before continuing

继续之前,请阅读以下重要信息

(2)Step 2 Select Destination Location

选择安装位置,非中文,无空格的目录。

(3)Step 3 Select Components

选择安装的组件,默认选择就好。

关于Git GUI Here。目前我都是使用Git Bash来进行操作。使用Git GUI确实可以得到更好的UI体验,不过个人认为会减低效率。并且初学者还是先搞懂Git的常用指令之后,再使用Git GUI才会有更好的理解。

说明:

(1)Additional icons: 附加图标

On the Desktop:在桌面上

(2)Windows Explorer integration Windows:资源管理器集成鼠标右键菜单

也就是说将下面两个功能,添加到右键菜单中。进入Git界面就通过Git Bash Here

Git Bash Here

Git GUI Here

(3)Git LFS (Large File Support):对大文件的支持。

(4)Associate .git/* configuration files with the default text editor:

设置打开.git配置文件的默认文本编辑器。

(5)Associate .sh files to be run with Bash:

将.sh文件关联到Bash运行,也就是是否让git打开.sh文件。默认设置。

(6)Use a TrueType font in all console windows:在所有控制台窗口中使用TrueType字体,默认设置。

(7)Check daily for Git for Windows updates:每天检查Git是否有Windows更新,默认设置。

(4)Step 4 Select Strat Menu Folder

创建开始菜单目录(开始菜单目录名设置),默认选择。

Don't create a Start Menu folder

不创建“开始”菜单文件夹,不勾选。

(5)Step 5 Choosing the default editor used by Git

选择Git使用的默认编辑器,vim就是我们日常所习惯的。默认选择。

说明:

Use the Nano editor by default:默认使用 Nano 编辑器。

Use Vim (The ubiquitous text editor) as Git's default editor:使用 Vim 作为 Git 的默认编辑器。

Use Notepad++ as Git's default editor:使用 Notepad++ 作为 Git 的默认编辑器。

Use Visual Studio Code as Git's default editor:使用 `Visual Studio Code`` 作为 Git 的默认编辑器。

Use Sublime Text as Git's default editor:使用 Sublime Text` 作为 Git 的默认编辑器。

可选操作根据自己习惯。

(6)Step 6 Adjusting your PATH environment

根据选择,配置相应的PATH环境变量。

说明:

(1)Use Git from Git Bash only

描述:This is the safest choice as your PATH will not be modified at all.You will only be able to use the Git command line tools form Git Bash.

翻译:这是最安全的选择,因为您的PATH根本不会被修改。您只能在 Git Bash 的使用 Git 命令行工具。

(2)Use Git from the Windows Command Prompt

描述:This option is considered safe as it only adds some minimal Git wrappers to your PATH to avoid cluttering your environment with optional Unix tools . You will be able to use Git from both Git Bash and the Windows Command Prompt.

翻译:这个选项被认为是安全的,因为它只向PATH添加一些最小的 Git包,以避免使用可选的Unix工具混淆环境。 您将能够从 Git Bash 和 Windows 命令提示符中使用 Git。(也就是在Windows的命令行cmd中也可以运行Git命令,操作上带来方便

(3)Use Git and optional Unix tools from the Windows Command Prompt

从Windows命令提示符使用Git和可选的Unix工具。

Both Git and the optional Unix tools will be added to you PATH

Git和可选的Unix工具都将添加到您计算机的 PATH 中。

Warning:This will override Windows tools like "find and sort".Only use this option if you understand the implications.

警告:这将覆盖Windows工具,如 “ find 和 sort ”这些命令。只有在了解其含义后才使用此选项。

  • 第一项简述:直接安装,不会配置Git命令的环境变量,需要手动配置环境变量。
  • 第二项:会自动配置好Git命令的环境变量。(默认选项)
  • 第三项:不推荐。

所以:新手推荐第二选项。熟练使用Git工具的,推荐第一选项。

(7)Step 7 Choosing HTTPS transport backend

选择本地库和远程库在连接的时候,使用哪一种连接方式。

也就是使用哪个加密库来加密HTTP传输的信息,默认是使用openssl,一般都是使用默认设置。

说明:

(1)Use the OpenSSL library

使用 OpenSSL 库。

Server certificates will be validated using the ca-bundle.crt file.

服务器证书将使用ca-bundle.crt文件进行验证。

(2)Use the native Windows Secure Channel library

使用本地 Windows 安全通道库。

Server certificates will be validated using Windows Certificate Stores.This option also allows you to use your company's internal Root CA certificates distributed e.g. via Active Directory Domain Services.

服务器证书将使用Windows证书存储验证。此选项还允许您使用公司的内部根CA证书,例如, 通过Active Directory Domain Services

(8)Step 8 Configuring the line ending conversions

选择提交的时候换行符格式

说明:

(1)Checkout Windows-style,commit Unix-style line endings

翻译:检查出Windows换行符格式转换为Unix换行符格式,再进行提交。

(2)Checkout as-is , commit Unix-style line endings**

翻译:不管检查出原来是什么换行符格式,一律转为Unix换行符格式的换行再进行提交。

(3)Checkout as-is,commit as-is

不进行换行符格式转换 : 不进行转换,检查出什么,就提交什么。

也就是提交代码时使用哪种风格,使用默认设置即可。

(9)Step 9 Configuring the terminal emulator to use with Git Bash

使用哪个软件作为Git的终端程序(也就是命令行终端,右键Git Bash Here出来的窗口风格),默认使用minTTY,还属于比较好用的终端,直接使用默认设置。

说明:

(1)Use MinTTY (the default terminal of MSYS2)

描述:Git Bash will use MinTTY as terminal emulator,which sports a resizable window,non-rectangular selections and a Unicode font. Windows console programs (such as interactive Python) must be launched via 'winpty' to work in MinTTY.

翻译:Git Bash将使用MinTTY作为终端模拟器,该模拟器具有可调整大小的窗口,非矩形选区和Unicode字体。 Windows控制台程序(如交互式Python)必须通过'winpty'启动才能在MinTTY中运行。

(2)Use Windows' default console window

描述:Git will use the default console window of Windows ("cmd.exe"),which works well with Win32 console programs such as interactive Python or node.js , but has a very limited default scroll-back,needs to be configured to use aUnicode font in order to display non-ASCII characters correctly,and prior to Windows 10 its windows was not freely resizable and it only allowed rectangular text selections.

翻译:Git将使用Windows的默认控制台窗口(“cmd.exe”),该窗口可以与Win32控制台程序(如交互式Python或node.js)一起使用,但默认的回滚非常有限,需要配置为使用unicode 字体以正确显示非ASCII字符,并且在Windows 10之前,其窗口不能自由调整大小,并且只允许矩形文本选择。

提示:选择选项一般都偏向于Linux方向,Windows方向不要选择。这样符合习惯。

(10)Step 10 Configuring extra options

配置额外的选项,如是否开启文件缓存之类的辅助功能,默认选择即可。

说明:

(1)Enable file system caching

启用文件系统缓存。

描述:File system data will be read in bulk and cached in memory for certain operations ("core.fscache" is set to "true"). This provides a significant performance boost.

翻译:文件系统数据将被批量读取并缓存在内存中用于某些操作(“core.fscache”设置为“true”)。 这提供了显着的性能提升。

(2)Enable Git Credential Manager

启用Git凭证管理器。

描述:The Git Credential Manager for Windows provides secure Git credential storage for Windows,most notably multi-factor authentication support for Visual Studio Team Services and GitHub. (requires .NET framework v4.5.1 or or later).

翻译:Windows的Git凭证管理器为Windows提供安全的Git凭证存储,最显着的是对Visual Studio Team Services和GitHub的多因素身份验证支持。 (需要.NET Framework v4.5.1或更高版本)。

(3)Enable symbolic links

启用符号链接。

描述:Enable symbolic links (requires the SeCreateSymbolicLink permission).Please note that existing repositories are unaffected by this setting.

翻译:启用符号链接(需要SeCreateSymbolicLink权限)。请注意,现有存储库不受此设置的影响。

(11)Step 11 Installing

进行安装。

(12)Step 12 Completing the Git Setup Wizard

完成Git安装向导。

进入cmd和Git客户端,输入git --version,查看版本信息,出现证明安装成功。

如下图所示:

在桌面右键,显示Git GUI HereGit Bash Here

Git不需要单独的服务器来安装,只需要在自己的电脑上安装Git就可以使用了。