Git 安装

进入Git的官网,下载最新版的Git客户端,我下载的是windows版本的

Git官网

选择安装组件,默认是添加两个功能到鼠标右键菜单,Git LFS是大文件支持,后面两个"associate ..."都是关联文件

安装程序

选择 Git 默认编辑器为Vim

image-20231222230846467

决定初始化新项目(仓库)的主干名字

第一种是让 Git 自己选择,名字是 master ,但是未来也有可能会改为其他名字;

image-20231222230950244
调整你的 path 环境变量

这里直接选择推荐的

Git from the command line and also from 3rd-party software (Recommended) This option adds only some minimal Git wrappers to your PATH to avoid cluttering your environment with optional Unix tools. You will be able to use Git from Git Bash, the Command Prompt and the Windov PowerShell as well as any third-party software looking for Git in PATH. 从命令行以及第三方软件进行 Git (推荐)此选项仅将一些最小的 Git 包装器添加到PATH中,以避免使用可选的 Unix 工具使环境混乱。 您将能够使用 Git Bash 中的 Git,命令提示符和 Windov PowerShell 以及在 PATH 中寻找 Git 的任何第三方软件。

能够从 Git Bash命令提示符(cmd)Windows PowerShell 以及可以从 Windows 系统环境变量中寻找 Git的任何第三方软件中使用 Git。推荐使用这个。

image-20231222231023029
选择 SSH 执行文件
image-20231222231102716
选择HTTPS后端传输

use the OpenSSL library Server certificates will be validated using the ca-bundle. crt file. 使用 OpenSSL 库 服务器证书将使用 ca-bundle.crt 文件进行验证。

image-20231222231112590

作为普通用户,只是用 Git 来访问 Github、GitLab 等网站,选择前者就行了。

2.2.10 配置行尾符号转换
image-20231222231125449

Checkout Windows-style, commit Unix-style line endings Git will convert LF to CRLF when checking out text files. When committing text files, CRLF will be converted to LF. For cross-platform projects, this is the recommended setting on Windows("core. autocrif"is set to "true"). 签出 Windows 样式,提交 Unix 样式的行结尾 Git 签出文本文件时,会将 LF 转换为 CRLF。 提交文本文件时,CRLF 将转换为 LF。 对于跨平台项目,这是 Windows 上的建议设置("core.autocrif" 设置为 "true")。

选择Windows type

2.2.11 配置终端模拟器以与 Git Bash 一起使用

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. 使用 MinTTY(MSYS2的默认终端) Git Bash 将使用 MinTTY 作为终端仿真器,该仿真器具有可调整大小的窗口非矩形选择和 Unicode 字体。 Windows 控制台程序(例如交互式 Python)必须通过 "winpty" 启动才能在 MinTTY 中运行。

建议选择第一种,MinTTY 3功能比 cmd 多,cmd 只不过 比 MinTTY 更适合处理 Windows 的一些接口问题,这个对 Git 用处不大,除此之外 Windows 的默认控制台窗口(cmd)有很多劣势,比如 cmd 具有非常有限的默认历史记录回滚堆栈和糟糕的字体编码等等。 相比之下,MinTTY 具有可调整大小的窗口和其他有用的可配置选项,可以通过右键单击的工具栏来打开它们 git-bash 。点击 [next] 到第十二步。

image-20231222231138720
2.2.12 选择默认的 “git pull” 行为

ODefault(fast-forward or merge) This is the standard behavior ofgit pull": fast-forward the current branch to the fetched branch when possible, otherwise create a merge commit. 默认(快进或合并) 这是 "git pull" 的标准行为:在可能的情况下将 当前分支 快进到 获取的分支,否则创建合并提交。

一般默认选择第一项,git rebase 绝大部分程序员都用不好或者不懂,而且风险很大,但是很多会用的人也很推崇,但是用不好就是灾难。

git pull 只是拉取远程分支并与本地分支合并,而 git fetch 只是拉取远程分支,怎么合并,选择 merge 还是 rebase ,可以再做选择。

image-20231222231147951
2.2.13 选择一个凭证帮助程序

第一个选项是提供登录凭证帮助的,Git 有时需要用户的凭据才能执行操作;例如,可能需要输入用户名密码才能通过 HTTP 访问远程存储库(GitHub,GItLab 等等)。

image-20231222231156975
2.2.14 配置额外的选项

启用文件系统缓存就是将批量读取文件系统数据并将其缓存在内存中以进行某些操作,可以显著提升性能。这个选项默认开启。 启用符号链接 ,符号链接是一类特殊的文件, 其包含有一条以绝对路径或者相对路径的形式指向其它文件或者目录的引用,类似于 Windows 的快捷方式,不完全等同 类Unix(如 Linux) 下的 符号链接。因为该功能的支持需要一些条件,所以默认不开启。

image-20231222231206136
2.2.15 配置实验性选项
image-20231222231214155

这是实验性功能,可能会有一些小错误之类的,建议不用开启。

设置Git用户名和邮箱

image-20231224151236556

Git 安装
http://example.com/2023/07/12/Git 安装/
作者
Brianyjh
发布于
2023年7月12日
许可协议