GIT中忽略的子文件夹中文件的名称太长

问题描述 投票:0回答:1

我试图在Github中从VS Code做一个简单的提交。

这是控制台上的输出:

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

这是我的.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

为什么GIT / VSCODE尝试在node_modules下提交一个应该被忽略的文件?

git visual-studio-code
1个回答
2
投票

您必须在gitignore文件的node_modules条目中附加斜杠。对于所有其他目录条目(例如coverage目录)也是如此。

gitignore文件中的固定行看起来像下面代码段中的固定行。

# Dependency directories
node_modules/

# Coverage directory used by tools like istanbul
coverage/
© www.soinside.com 2019 - 2024. All rights reserved.