windows Git 状态需要很长时间才能完成
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1183769/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git Status Takes a Long Time to Complete
提问by Matt McMinn
I'm using git
to manage files in a local directory on a Windows machine - no network is involved here, I'm not pushing or pulling to/from another machine. My directory has maybe 100 files in it, all test files, pretty small. When I run git status
, it regularly takes 20-30 seconds to complete. Is this normal? Is there anything I can do to speed it up, or a better way to see what the state of my repository is (changed files, untracked files, etc)? Other git
commands seem to complete much faster.
我git
用来管理 Windows 机器上本地目录中的文件 - 这里不涉及网络,我不会向/从另一台机器推送或拉动。我的目录中可能有 100 个文件,所有测试文件都非常小。当我运行时git status
,它通常需要 20-30 秒才能完成。这是正常的吗?我能做些什么来加快速度,或者有什么更好的方法来查看我的存储库的状态(已更改的文件、未跟踪的文件等)?其他git
命令似乎完成得更快。
回答by Scott
回答by Sarge
On a similar issue I found that having a git repo in a directory below my existing git repo caused a massive slow down.
在一个类似的问题上,我发现在我现有的 git repo 下的目录中有一个 git repo 会导致严重的减速。
I moved the secondary git repo somewhere else and now the speed is fast!
我将辅助 git repo 移到其他地方,现在速度很快!
回答by 1800 INFORMATION
Are you using some kind of virus protection software? Maybe that is interfering with things. git
is very fast for me on windows with repositories of 1000's of files.
您是否在使用某种病毒防护软件?也许那是在干扰事情。git
在具有 1000 个文件存储库的 Windows 上对我来说非常快。
回答by thedz
Have you tried repacking? git-repack.
你试过重新打包吗?git-repack。
Otherwise, try duplicating the directory, and deleting the .git folder in the duplicated directory. Then create a new git directory and see if it's still slow.
否则,尝试复制目录,并删除复制目录中的 .git 文件夹。然后新建一个git目录,看看是不是还慢。
If it's still slow, then it sounds like a system or hardware issue. Git finishes status on hundreds of files for me in less than 5 seconds.
如果它仍然很慢,那么这听起来像是系统或硬件问题。Git 在不到 5 秒的时间内为我完成了数百个文件的状态。
回答by DanJAB
For some reason git status
is particularly slow after moving or copying the repository folder to a new location.
由于某种原因,git status
在将存储库文件夹移动或复制到新位置后特别慢。
Subsequent runs are usually quicker in this case.
在这种情况下,后续运行通常会更快。
回答by Arigion
My git status
was very slow (up to one minute), because the global .gitignore
file was located in my windows userprofile, which was stored on an inaccessible network share.
我的git status
速度很慢(最多一分钟),因为全局.gitignore
文件位于我的 Windows 用户配置文件中,该文件存储在无法访问的网络共享中。
git config --global core.excludesfile
showed something like \\Nxxxx0\User\Username\Eigene Dateien\gitignore_global.txt
git config --global core.excludesfile
显示了类似的东西 \\Nxxxx0\User\Username\Eigene Dateien\gitignore_global.txt
For some reason \\Nxxxx0
was inaccessible and my userprofile was loaded from a backup system \\Nxxxxx1
. It took some time to figure that out, because usually my userprofile is bound to a drive letter by an enterprise startup script and accessing that drive letter was working as usual.
I'm not sure why the git-config used the network share and not the drive letter (probably a younger me is to blame)
由于某种原因\\Nxxxx0
无法访问,我的用户配置文件是从备份系统加载的\\Nxxxxx1
。花了一些时间才弄清楚这一点,因为通常我的用户配置文件通过企业启动脚本绑定到驱动器号,并且访问该驱动器号可以像往常一样工作。我不知道为什么 git-config 使用网络共享而不是驱动器号(可能是我年轻的罪魁祸首)
After setting git config --global core.excludesfile $HOME/Eigene\ Dateien/gitignore_global.txt
git status
was back to normal speed.
设置git config --global core.excludesfile $HOME/Eigene\ Dateien/gitignore_global.txt
git status
后恢复正常速度。
回答by Bill
Running git fsck
has resolved this issue for me in the past.
跑步git fsck
过去已经为我解决了这个问题。
回答by M. K. Hunter
For me, the slowness was due to having a lot of untracked files (temporary and output files from scripts.) Running git status -uno
, which excludes the untracked files, ran much faster, and meets my requirements
对我来说,缓慢是由于有很多未跟踪的文件(来自脚本的临时文件和输出文件)。 Running git status -uno
,它排除了未跟踪的文件,运行得更快,并且满足我的要求
回答by Brett
Older versions of git have a performance issue with git status - see Ways to improve git status performancefor more info.
旧版本的 git 存在 git status 的性能问题 -有关更多信息,请参阅提高 git status 性能的方法。
git 2.13 has 1 fix, and 2.17 more. i moved from 2.7 to 2.23 and it resolved slow status. There is another improvement planned for 2.24 soon.
git 2.13 有 1 个修复,还有 2.17 个。我从 2.7 移动到 2.23,它解决了缓慢的状态。很快计划在 2.24 中进行另一项改进。
回答by Hyman Perry
The issue for me was that I had a lot of different repositories cloned onto my local hard drive, the more repos you have the longer it will take to run commands like git status.
对我来说,问题是我有很多不同的存储库克隆到我的本地硬盘驱动器上,您拥有的存储库越多,运行 git status 之类的命令所需的时间就越长。
I simply deleted a lot of the repos which I no longer needed locally, and my git status went from 1minute~ to 5 seconds.
我只是删除了很多本地不再需要的存储库,我的 git 状态从 1 分钟到 5 秒。
I can't see any answers similar to this here.
我在这里看不到任何与此类似的答案。