Git 环境搭建指南
一、安装配置建议
在安装向导中,以下选项建议按如下方式配置,以确保后续开发流程顺畅:
| 配置项 | 建议选择 | 原因 |
|---|---|---|
| 组件选择 | 保留默认勾选,取消 Check daily for updates | 自动更新非必需,核心功能已足够 |
| 默认编辑器 | Use Visual Studio Code as Git's default editor | 避免 Vim 学习成本,统一开发工具链 |
| 初始分支名 | Override,填入 main | 适配 GitHub/Gitee 等主流平台规范 |
| PATH 配置 | Git from the command line and also from 3rd-party software | 支持 Git Bash、CMD 及 VSCode 多终端调用 |
| SSH 客户端 | Use bundled OpenSSH | 自带工具兼容性更好,无需额外安装 |
| HTTPS 后端 | Use the native Windows Secure Channel library | 系统原生适配,减少证书管理麻烦 |
| 换行符处理 | Checkout Windows-style, commit Unix-style | 解决跨平台协作时的换行冲突问题 |
| 终端模拟器 | Use MinTTY | 界面更友好,支持窗口缩放 |
git pull 行为 | Fast-forward or merge | 保留提交历史,适合个人及团队协作 |
| 凭证管理器 | Git Credential Manager | 自动保存账号密码,免去重复输入 |
| 额外选项 | 启用 Enable file system caching,取消 Enable symbolic links | 提升性能,Windows 下符号链接兼容性较差 |
二、初始化全局配置
安装完成后,打开 Git Bash 执行以下命令配置用户信息。请将占位符替换为你自己的真实信息。
git config --global user.name
git config --global user.email

