我正在尝试从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下提交一个应该被忽略的文件?
答案 0 :(得分:2)
您必须在gitignore文件的node_modules条目中附加斜杠。对于所有其他目录条目(例如coverage目录)也是如此。
gitignore文件中的固定行看起来与以下代码段中的固定行相似。
# Dependency directories
node_modules/
# Coverage directory used by tools like istanbul
coverage/
答案 1 :(得分:0)
我遇到了同样的错误,这是因为您的 git 配置限制了文件名的长度。一种可能的解决方案是以管理员身份使用以下命令更改此配置。祝你好运!
git config --system core.longpaths true