git在Windows和Linux之间切换后强制刷新索引 [英] git forces refresh index after switching between windows and linux

查看:647
本文介绍了git在Windows和Linux之间切换后强制刷新索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Windows和Linux共享的磁盘分区(格式:NTFS).它包含一个git存储库(约6.7G).
如果我仅使用Windows 仅使用linux 来操作git存储库,则一切正常.
但是每次我切换系统时. git status命令将刷新索引,大约需要1分钟.运行git status后,如果再次在同一系统中运行git status.仅需不到1秒的时间.这是结果

I have a disk partition (format: NTFS) shared by windows and linux. It contains a git repository(about 6.7G).
If I only use windows or only use linux to manipulate the git repository everything is ok.
But everytime I switch the system. The git status command will refresh the index and takes about 1minute. After I running the git status, if I run the git status in the same system again. It only take less than 1 second. Here is the result

# Just after switch from windows
[#5#wangx@manjaro:duishang_design] git status  # this command takes more than 60s
Refresh index: 100% (2751/2751), done.
On branch master
nothing to commit, working tree clean

[#10#wangx@manjaro:duishang_design] git status  # this time the command takes less than 1s
On branch master
nothing to commit, working tree clean

[#11#wangx@manjaro:duishang_design] git status  # this time the command takes less than 1s
On branch master
nothing to commit, working tree clean

我想git缓存有一些问题.例如:Windows和Linux都使用.git/index文件作为缓存文件,但是linux系统中的git无法识别Windows更改的.git/index.因此,它只能刷新索引并替换.git/index文件,这会使Windows中的下一个git status超级快,而git status则非常慢(因为Windows系统将再次刷新索引文件).

I guess there is some problem about the git cache. For example: windows and linux all use the .git/index file as cache file, but the git in linux system can't recognize the .git/index changed by windows. So it can only refresh the index and replace the .git/index file, which makes the next git status super fast and git status in windows very slow (because the windows system will refresh the index file again).

我的猜测正确吗?如果是这样,我如何为不同的系统使用设置索引文件?我该如何解决这个问题?

Is my guess correct? If so, how can I use set the index file for different system? How can I solve the problem?

推荐答案

如torek所述,您可能不想这样做.在操作系统之间共享存储库通常不是一个好主意.

As torek mentioned, you probably don't want to do this. It's not generally a good idea to share a repo between operating systems.

但是,有可能,就像有可能在Windows和Linux的Windows子系统之间共享一个回购协议一样.您可能需要尝试将core.checkStat设置为minimal,如果还不够,请将core.trustctime设置为false.这导致索引中存储的信息量最少,这意味着数据将尽可能地具有可移植性.

However, it is possible, much like it's possible to share a repo between Windows and Windows Subsystem for Linux. You may want to try setting core.checkStat to minimal, and if that isn't sufficient, core.trustctime to false. That leads to the minimal amount of information being stored in the index, which means that the data is going to be as portable as possible.

但是,请注意,如果您的存储库具有符号链接,则很可能您无所事事将阻止刷新. Linux通常将符号链接的长度视为其长度(以字节为单位),而Windows则认为其占用一个或多个磁盘块,因此操作系统之间的大小将不匹配.这是不可避免的,因为大小是无法禁用的索引中使用的属性之一.

Note, however, that if your repository has symlinks, that it's likely that nothing you do is going to prevent refreshes. Linux typically considers the length of a symlink to be its length in bytes, and Windows considers it to take one or more disk blocks, so there will be a mismatch in size between the operating systems. This isn't avoidable, since size is one of the attributes used in the index that can't be disabled.

这篇关于git在Windows和Linux之间切换后强制刷新索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆