具体设置方法
方式1
You can significantly speed up Git on Windows by running three commands to set some config options:
git config --global core.preloadindex true
git config --global core.fscache true
git config --global gc.auto 256
Notes:
-
core.preloadindex
does filesystem operations in parallel to hide latency (update: enabled by default in Git 2.1) -
core.fscache
fixes UAC issues so you don’t need to run Git as administrator (update: enabled by default in Git for Windows 2.8) -
gc.auto
minimizes the number of files in .git/
方式2
备注:可以方式1 方式2 都设置,设置了方式1 感觉提升不大
修改 git 配置文件 profile(我的路径为 C:\Program Files\Git\etc)
添加位置为profile PS1 最后出现位置的下方 我的是
添加内容:
fast_git_ps1 ()
{
printf -- "$(git branch 2>/dev/null | sed -ne '/^\* / s/^\* \(.*\)/ [\1] / p')"
}
PS1='\[\033]0;$MSYSTEM:\w\007
\033[32m\]\u@\h \[\033[33m\w$(fast_git_ps1)\033[0m\]
$ '
这么设置的原因,是因为,git bash 格式化输出、渲染太多,导致执行命令后,反应较慢
方式3
执行命令
export PS1='$'
这个设置是 格式化输出替换为 $
符号,速度提升较大 效果如下
方式4
卸载-重启-安装,一路next,使用默认配置。(知乎方法,并未尝试)
效果对比
设置 方式1 方式2 前
设置 方式1 方式2 后
其他
查看当前系统用户目录
- 在cmd下输入echo %USERPROFILE% 或者 cmd 下输入 set HOME
调试 git status 命令
- GIT_TRACE=true git status
显示耗时
- time GIT_TRACE=true git status
参考链接
1、Diagnosing performance issues
2、painfully - git status slow
3、installer: offer the builtin stash/rebase as experimental options
4、Git Bash is extremely slow on Windows 7 x64
5、Git commands have a 2-3 second delay before returning to the prompt #1070
6、What is the meaning of these Windows Environment variables: HOMEDRIVE, HOMEPATH, HOMESHARE, USERPROFILE
7、提高win10 系统 git 速度的方法