简体   繁体   English

被忽略的子文件夹中的文件名对于 GIT 来说太长了

[英]Name of a file in an ignored subfolder too long for GIT

I am trying to do a simple commit from VS Code in Github.我正在尝试从 Github 中的 VS Code 做一个简单的提交。

This is the output on the console:这是控制台上的输出:

git add -A -- .
warning: LF will be replaced by CRLF in dist/factory-method-web-part.js.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in lib/webparts/factoryMethod/components/FactoryMethod.d.ts.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in lib/webparts/factoryMethod/components/FactoryMethod.js.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in lib/webparts/factoryMethod/components/ListItemFactory.js.
The file will have its original line endings in your working directory.
error: open("node_modules/@microsoft/office-ui-fabric-react-bundle/node_modules/office-ui-fabric-react/lib-amd/components/ChoiceGroup/examples/ChoiceGroup.Custom.Example.scss.d.ts"): Filename too long
error: unable to index file node_modules/@microsoft/office-ui-fabric-react-bundle/node_modules/office-ui-fabric-react/lib-amd/components/ChoiceGroup/examples/ChoiceGroup.Custom.Example.scss.d.ts
fatal: updating files failed

git status -z -u
git symbolic-ref --short HEAD
git rev-parse master
git rev-parse --symbolic-full-name --abbrev-ref master@{u}
git rev-list --left-right master...origin/master
git for-each-ref --format %(refname) %(objectname)
git remote --verbose

This is the content of my .gitignore file:这是我的 .gitignore 文件的内容:

# Logs
logs
*.log
npm-debug.log*

# Dependency directories
node_modules

# Build generated files
dist
lib
solution
temp
*.sppkg

# Coverage directory used by tools like istanbul
coverage

# OSX
.DS_Store

# Visual Studio files
.ntvs_analysis.dat
.vs
bin
obj

# Resx Generated Code
*.resx.ts

# Styles Generated Code
*.scss.ts

Why is GIT/VSCODE trying to commit a file under node_modules which should be ignored?为什么 GIT/VSCODE 试图在 node_modules 下提交一个应该被忽略的文件?

You have to append a slash to the node_modules entry in your gitignore file.您必须在 gitignore 文件中的 node_modules 条目后附加一个斜杠。 This is also true for all the other directory entries, like the coverage directory.对于所有其他目录条目也是如此,例如覆盖目录。

Your fixed lines in the gitignore file would look like the ones in the following snippet. gitignore 文件中的固定行类似于以下代码段中的行。

# Dependency directories
node_modules/

# Coverage directory used by tools like istanbul
coverage/

I had the same error and it happens because your git configuration limits the length of the filenames.我遇到了同样的错误,这是因为您的 git 配置限制了文件名的长度。 One of the possible solutions is to change this config using the below command as Administrator.一种可能的解决方案是以管理员身份使用以下命令更改此配置。 Good luck!祝你好运!

git config --system core.longpaths true

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

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