无法将所有文件添加到 Cloud GIT 存储库

问题描述

我在本地的 Spark Scala 上运行了一个项目。我能够成功地构建它,没有任何问题。

我在将该项目复制到本地的 git 文件夹时遇到问题。它说某些文件名太长。所以我不得不跳过那些文件来完成复制任务。

enter image description here

嗯,这不是我面临的实际问题。运行时将项目目录复制到本地 git 文件夹后:

git add spark-pm-cm/

我不断收到一些警告和错误消息,例如:

warning: LF will be replaced by CRLF in spark-pm-cm/null/Coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-sbt/ipcsocket/ipcsocket/1.0.0/ipcsocket-1.0.0.pom.
The file will have its original line endings in your working directory

The file will have its original line endings in your working directory
error: open("spark-pm-cm/null/Coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-sbt/ivy/ivy/2.3.0-sbt-cb9cc189e9f3af519f9f102e6c5d446488ff6832/.ivy-2.3.0-sbt-cb9cc189e9f3af519f9f102e6c5d446488ff6832.jar.checked"): Filename too long
error: unable to index file 'spark-pm-cm/null/Coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-sbt/ivy/ivy/2.3.0-sbt-cb9cc189e9f3af519f9f102e6c5d446488ff6832/.ivy-2.3.0-sbt-cb9cc189e9f3af519f9f102e6c5d446488ff6832.jar.checked'
fatal: adding files failed

我正在尝试将此代码推送到 Google Cloud 上的 Git 存储库。

解决方法

如果您是在 windows 机器上工作的单个开发人员,并且您不关心 git 自动将 LFs 替换为 CRLFs,您可以通过在 git 命令行中键入以下内容来关闭此警告

git config core.autocrlf true

Git 的文件名限制为 4096 个字符,但在 Windows 上使用 msys 编译 Git 时除外。它使用旧版本的 Windows API,文件名限制为 260 个字符。

git config --system core.longpaths true

在您的 git bash 中以管理员身份运行这些命令应该可以完成这项工作!

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...