git 结帐时出错。路径太长
Error at git checkout. Path too long
当我在克隆 repo 后尝试结帐到另一个分支时,我在 Git 中遇到此错误:
git -c diff.mnemonicprefix=false -c core.quotepath=false checkout develop
fatal: cannot create directory at 'node_modules/karma/node_modules/chokidar/node_modules/anymatch/node_modules/micromatch/node_modules/braces/node_modules/expand-range/node_modules/fill-range/node_modules/isobject/node_modules/isarray/build': Filename too long
node_modules
文件夹不再重要 git
(我把文件夹node_modules/
放在了.gitignore
)但是我总是报这个错。
这似乎是路径太长的问题,因为如果我尝试在资源管理器中导航,我会遇到路径太长的 windows 错误。
I put the folder nodemodules/ in .gitignore
您需要:
- 将
node_modules/
放入.gitignore
,而不是nodemodules/
记录从 git 存储库中删除 node_modules/
文件夹
git rm -r --cached -- node_modules/
然后您可以提交,并再次尝试结帐。
OP padibro confirms 版本问题:
I have updated git from 1.7.x to 2.7.4 (embedded git of sourcetree on windows) and now works fine
如“Git cannot create a file or directory with a long path", PR 122 added core.longpaths
in Git for Windows only for git 1.9.0 等所述。
当我在克隆 repo 后尝试结帐到另一个分支时,我在 Git 中遇到此错误:
git -c diff.mnemonicprefix=false -c core.quotepath=false checkout develop
fatal: cannot create directory at 'node_modules/karma/node_modules/chokidar/node_modules/anymatch/node_modules/micromatch/node_modules/braces/node_modules/expand-range/node_modules/fill-range/node_modules/isobject/node_modules/isarray/build': Filename too long
node_modules
文件夹不再重要 git
(我把文件夹node_modules/
放在了.gitignore
)但是我总是报这个错。
这似乎是路径太长的问题,因为如果我尝试在资源管理器中导航,我会遇到路径太长的 windows 错误。
I put the folder nodemodules/ in .gitignore
您需要:
- 将
node_modules/
放入.gitignore
,而不是nodemodules/
记录从 git 存储库中删除
node_modules/
文件夹git rm -r --cached -- node_modules/
然后您可以提交,并再次尝试结帐。
OP padibro confirms
I have updated git from 1.7.x to 2.7.4 (embedded git of sourcetree on windows) and now works fine
如“Git cannot create a file or directory with a long path", PR 122 added core.longpaths
in Git for Windows only for git 1.9.0 等所述。