方式一:
PS C:\WINDOWS\system32> git update Warning! `git update` has been deprecated; Please use `git update-git-for-windows` instead. Git for Windows 2.24.1.windows.2 (64bit) Update 2.25.0.windows.1 is available Download and install Git for Windows 2.25.0 [N/y]? y PS C:\WINDOWS\system32>
參考
https://segmentfault.com/q/1010000011704285
https://segmentfault.com/a/1190000004317077
方式二:
https://chocolatey.org/packages/git
首先安裝chocolatey,操作步驟請參考https://chocolatey.org/install
- 以管理員身份運行 CMD或者PowerShell,輸入以下命令
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
PS C:\Windows\system32> Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) Getting latest version of the Chocolatey package for download. Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.15. Downloading 7-Zip commandline tool prior to extraction. Extracting C:\Users\[UserName]\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\[UserName]\AppData\Local\Temp\chocolatey\chocInstall... Installing chocolatey on this machine Creating ChocolateyInstall as an environment variable (targeting 'Machine') Setting ChocolateyInstall to 'C:\ProgramData\chocolatey' WARNING: It's very likely you will need to close and reopen your shell before you can use choco. Restricting write permissions to Administrators We are setting up the Chocolatey package repository. The packages themselves go to 'C:\ProgramData\chocolatey\lib' (i.e. C:\ProgramData\chocolatey\lib\yourPackageName). A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin' and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'. Creating Chocolatey folders if they do not already exist. WARNING: You can safely ignore errors related to missing log files when upgrading from a version of Chocolatey less than 0.9.9. 'Batch file could not be found' is also safe to ignore. 'The system cannot find the file specified' - also safe. chocolatey.nupkg file not installed in lib. Attempting to locate it from bootstrapper. PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding... 警告: Not setting tab completion: Profile file does not exist at 'D:\[UserName]\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'. Chocolatey (choco.exe) is now ready. You can call choco from anywhere, command line or powershell by typing choco. Run choco /? for a list of functions. You may need to shut down and restart powershell and/or consoles first prior to using choco. Ensuring chocolatey commands are on the path Ensuring chocolatey.nupkg is in the lib folder PS C:\Windows\system32>
- 等待執行完成,輸入choco /? 或者 choco version驗證是否安裝成功
PS C:\Windows\system32> choco version Chocolatey v0.10.15 DEPRECATION NOTICE - choco version command is deprecated and will be removed in version 1.0.0. Please use `choco upgrade pkgname --noop` instead. _ Chocolatey:ChocolateyVersionCommand - Noop Mode _ chocolatey v0.10.15 is the latest version available based on your source(s). Chocolatey can upgrade 0/1 packages. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log). PS C:\Windows\system32>
- 安裝成功后,使用choco命令更新git到最新版本
PS C:\Windows\system32> choco install -y git
總結
方式一:使用的是git-scm官方源,由於官方源文件使用的是亞馬遜雲的服務器,國內訪問非常慢,很難更新成功,如果更新成功真的是拼網絡運行商的網了,成敗看人品
方式二:是換Chocolatey的安裝源,不過首先要安裝Chocolatey命令工具,使用choco命令來更新git到最新版本,
windows 10 1909 (OS 內部版本 18363.836)已驗證,訪問速度還是挺快的,推薦