linux bash git 目录反应慢_提高win10 系统 git 速度的方法

不知是从何时起,win10 系统下的git 速度变的奇慢无比,比如用vs code进行view history、stage all changes、commit staged等操作时,可能需要等待几分钟。初步判断是哪里出了问题。

用百度在网上一搜,发现与我遇到同样问题的同学不少。百度搜索结果如下:

30af6fd66208774e9010c2c9f7085a77.png
百度搜索截图

有说是(1)双显卡的问题,(2)有说是杀毒软件的问题,(3)有说是windows 文件系统NTFS的问题等等。

方法(1)、(2)我试验过,无法解决问题——git的速度没有任何提升。
方法(3)没有尝试,因为我不可能为了做这个小试验把硬盘格式化。

问题没有解决,于是使用谷歌搜了一下,同样发现与我遇到同样问题的人不少,有搜索结果截图为证:

766a6034d2e3ea1163d734292e920518.png
谷歌搜索截图

于是挨个点进去,看了一下,基本上与百度搜索提供的方法一样,此外还提供了方法(4)

通过设置全局配置选项,方法截图如下:

f0e7e9525491880f552f703291faa78c.png
设置全局选项

具体设置方法如下:

git config --global core.preloadindex true
git config --global core.fscache true
git config --global gc.auto 256

然后我立马试验了一下,结果在vs code中各种git命令速度有了飞一般的提升。

当然还提供方法(5),截图如下:

41181da8bad72ea3ef12d5321d3ed56a.png
方法5

具体设置方法如下:

Another speedup came when I redefined my shell prompt. By default, the bash shows you which branch you're currently on, and for some reason the method it uses to get the branch is quite slow.
I found the following change on a StackOverflow post that seems to work way faster:
Go to your git install directory (Mine is c:Program Files (x86)Git
In the etc folder, open the file 'profile' in a text editor
This file is executed when the bash shell is initialized, you can do a lot of customization in here
Near the bottom, you will find some commands related to setting a variable called PS1 (PS1 = ...)
Either replace it or just append the following lines after it
fast_git_ps1 ()
{
    printf -- "$(git branch 2>/dev/null | grep -e '* ' | sed 's/^..(.*)/ {1} /')"
}

PS1='[033]0;$MSYSTEM:w007
033[32m]u@h [033[33mw$(fast_git_ps1)033[0m]
$
Make sure the PS1 variable is not changed again later in the script.

These tips all came from a StackOverflow post: http://stackoverflow.com/questions/4485059/git-bash-is-extremely-slow-in-windows-7-x64, there may be more there to help, but just the above changes made a massive change for me.

当然,方法(5)我没有尝试,有兴趣的可以试验一下。

以上是解决win 10 系统下git 慢的一点总结,希望能帮到遇到有同样问题的同学。


刚刚在知乎,找到了一个另外一个方法(6)——卸载-重启-安装。

有兴趣的同学可以试验一下方法(6)。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值