Git高速下载
程序员面试资料大全|各种技术书籍等资料-1000G
一、安装前准备:避免环境冲突
1. 检查系统残留(Windows)
# 检查旧版Git残留
where git
where git.exe# 检查环境变量
$env:PATH -split ';' | Select-String 'git'# 清理残留(管理员权限)
Uninstall-Module -Name Git -AllVersions -Force
Remove-Item -Path "C:\Program Files\Git" -Recurse -Force
2. 验证系统兼容性
系统版本 | 支持情况 | 注意事项 |
---|---|---|
Windows 7 | ⚠️ 仅Git 2.34以下 | 需安装KB4490628补丁 |
macOS 10.13- | ⚠️ 需升级命令行工具 | 安装Xcode Command Line Tools |
Ubuntu 16.04 | ⚠️ 需PPA源 | 使用git-core PPA |
CentOS 7 | ⚠️ 版本较旧 | 需IUS仓库升级 |
3. 权限准备
# Linux/macOS 确保有sudo权限
id -u # 返回0表示root# Windows 关闭杀毒软件实时防护
Set-MpPreference -DisableRealtimeMonitoring $true
二、Windows安装避坑指南
1. 安装包选择
- 官方推荐:Git for Windows
- 版本陷阱:
- 32位系统选
Git-2.xx.x-32-bit.exe
- ARM设备选
Git-2.xx.x-arm64.exe
- 32位系统选
2. 安装步骤关键配置
避坑配置详解:
-
组件选择(必须勾选):
- Git Bash Here
- Git GUI Here
- Associate .git* files
- Check daily for updates (避免自动升级冲突)
-
环境变量配置:
- 选 “Git from the command line and also from 3rd-party software”
- 避免选"Use Git from Git Bash only"
-
行尾转换:
- 选 “Checkout as-is, commit as-is”
- 避免Windows/Unix换行符混用问题
-
终端模拟器:
- 选 “Use Windows’ default console window”
- 避免MinTTY兼容性问题
3. 安装后验证
# 验证安装
git --version# 检查关键配置
git config --global -l | Select-String core.autocrlf# 正确应显示
core.autocrlf=false
4. 常见问题解决
问题:git
命令无法识别
✅ 解决方案:
- 重启所有终端
- 检查环境变量:
echo %PATH%
- 手动添加路径:
C:\Program Files\Git\cmd
问题:SSH认证失败
✅ 解决方案:
# 重新生成密钥
ssh-keygen -t ed25519 -C "your_email@example.com"# 添加密钥到agent
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_ed25519
三、macOS安装避坑指南
1. 安装方式对比
2. Homebrew安装(推荐)
3. 官方安装包问题解决
4. 常见问题
问题:xcrun: error: invalid active developer path
✅ 解决方案:
xcode-select --install
sudo xcode-select --switch /Library/Developer/CommandLineTools
问题:brew install 卡在Cloning…
✅ 解决方案:
四、Linux安装避坑指南
1. 各发行版安装命令
2. 权限问题解决
3. 配置优化
# 提高大仓库性能
git config --global core.preloadIndex true
git config --global core.fscache true
git config --global pack.threads 8# 设置默认编辑器(避免vim陷阱)
git config --global core.editor "code --wait"
程序员面试资料大全|各种技术书籍等资料-1000G
Git高速下载