現象描述
Windows 10 運行 GitHubSetup.exe 安裝失敗,嘗試 IE 設置可信站點後仍報錯。
核心原因排查
- 安裝包下載不全/損壞:官網直鏈在國內極慢,建議使用鏡像站(如
https://github.com/git-for-windows/git/releases/download/...)或迅雷下載。
- 殺毒軟件攔截:Windows Defender/360/火綠可能誤攔截安裝程序寫入註冊表、創建服務。暫時關閉實時防護再安裝。
- 路徑含中文/特殊字符:安裝目錄請使用純英文路徑,如
D:\Git。
- 缺少系統依賴:需預裝 Visual C++ Redistributable 2015-2022 (x64)。
- 權限不足:右鍵安裝包選「以管理員身份運行」。
推薦安裝流程
- 從 npmmirror 鏡像 下載最新
Git-2.x.x-64-bit.exe。
- 關閉殺毒軟件,右鍵以管理員身份運行。
- 安裝選項保持默認,關鍵節點確認:
- Adjusting your PATH environment → 選 Git from the command line and also from 3rd-party software。
- Choosing the SSH executable → 選 Use bundled OpenSSH。
- Configuring the line ending conversions → 選 Checkout Windows-style, commit Unix-style。
- 安裝完成後,PowerShell 執行
git --version 驗證。
替代方案
- Scoop:
scoop install git 一鍵安裝並管理版本。
- Chocolatey:
choco install git.install。
- Git for Windows Portable:解壓即用,無需安裝,適合 U 盤攜帶。
驗證 SSH 金鑰生成
ssh-keygen -t ed25519 -C "your_email@example.com"
# 按三次回車,公鑰在 ~/.ssh/id_ed25519.pub
cat ~/.ssh/id_ed25519.pub # 複製到 GitHub Settings → SSH Keys