简体   繁体   English

GIT > 20k 新文件阻塞了 VSCode UI,“活动更改过多”

[英]GIT > 20k new files chokes VSCode UI, "Too many active changes"

I am trying to add a folder that has to be tracked, however it is > 1GB / > 20k files.我正在尝试添加一个必须被跟踪的文件夹,但它是 > 1GB / > 20k 文件。

As soon I add it, I will get warning about too many active changes and Git simply will refuse to work correctly (on VS Code after the warning I cannot commit anything is it says there is no changes (yet left side button shows that there are changes)).一旦我添加它,我就会收到关于太多活动更改的警告,而 Git 只会拒绝正常工作(在 VS Code 上警告后我无法提交任何内容是说没有更改(但左侧按钮显示有变化))。

Tried to use command line but simply doesn't push new folder :/尝试使用命令行,但根本不推送新文件夹:/

Any advice how to deal with lots of new files ?任何建议如何处理大量新文件? I will have ~ 5-6x folders between 1GB - 5GB and from 20k - 200k filer per folder.我将在每个文件夹 1GB - 5GB 和 20k - 200k 文件管理器之间有 ~ 5-6x 文件夹。

I've ran into similar problems with VS Code.我遇到了与 VS Code 类似的问题。 If you are currently stuck where VS Code git extension keep repeating this message, put the offending folder in .gitignore then delete the git object cache for it.如果您当前卡在 VS Code git 扩展不断重复此消息的地方,请将有问题的文件夹放在 .gitignore 中,然后为其删除 git 对象缓存。

git rm -r --cached path/to/folder

A good strategy for large amount of files in VS Code is to compartmentalize each folder and commit separately as stated by Lasse.对于 VS Code 中的大量文件,一个好的策略是按照 Lasse 的规定划分每个文件夹并单独提交。

Something like in .gitignore structure of splitting the folder like this像这样拆分文件夹的 .gitignore 结构

folder/folderA
folder/folderB
folder/folderC

Remove one at a time and commit, and be as granular as required.一次删除一个并提交,并根据需要进行细化。 Rinse and repeat.冲洗并重复。 And if you have phpstorm use that instead for these large commits.如果您有 phpstorm,请使用它来代替这些大型提交。

Should you really be pushing this many files to a git repo?您真的应该将这么多文件推送到 git 仓库吗? Adding multiple gigabytes of files to a git repo is considered a bad practice.将数 GB 的文件添加到 git repo 被认为是一种不好的做法。

For example Github.com requests that git repos be less than 1GB例如 Github.com 要求 git repos小于 1GB

Consider the following approaches考虑以下方法

Git LFS Git LFS

https://git-lfs.github.com/ https://git-lfs.github.com/
Git LFS is a plugin that is designed to store binary files. Git LFS 是一个旨在存储二进制文件的插件。 They are managed with git, but are stored externally.它们由 git 管理,但存储在外部。 This is considered the best approach for when you must have large files in a git repo.当您必须在 git 存储库中有大文件时,这被认为是最佳方法。

Dependency Resolver依赖解析器

If the files that are being added to the git repo are external dependencies, consider looking at a dependency resolver to fetch the dependencies on demand.如果添加到 git repo 的文件是外部依赖项,请考虑查看依赖项解析器以按需获取依赖项。

Javascript/Node - npm Javascript/节点 - npm
Ruby - bundler Ruby -打包器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM