Programing

Windows 용 Git에서 파일 이름이 너무 깁니다.

lottogame 2020. 10. 4. 10:16
반응형

Windows 용 Git에서 파일 이름이 너무 깁니다.


Git-1.9.0-preview20140217Windows 용으로 사용 하고 있습니다. 아시다시피이 릴리스는 파일 이름이 너무 긴 문제를 해결해야합니다. 하지만 나는 아닙니다.

분명히 내가 뭔가 잘못하고 있어요 : 내가 그랬어 git config core.longpaths truegit add .다음 git commit. 모든 것이 잘되었습니다. 그러나 이제를 수행하면 git status다음과 같은 파일 목록이 표시됩니다 Filename too long.

node_modules/grunt-contrib-imagemin/node_modules/pngquant-bin/node_modules/bin-wrapper/node_modules/download/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js: Filename too long

나를 위해 재현하는 것은 매우 간단 합니다. Angular 생성기 ( "yo angular") Yeoman 웹 애플리케이션을 만들고 파일 node_modules에서 제거하기 만하면 .gitignore됩니다. 그런 다음 앞서 언급 한 Git 명령을 반복합니다.

내가 여기서 무엇을 놓치고 있습니까?


Git은 Windows에서 msys로 컴파일되는 경우를 제외하고 파일 이름에 대해 4096 자로 제한됩니다. 이전 버전의 Windows API를 사용하며 파일 이름은 260 자로 제한됩니다.

내가 이것을 이해하는 한, 그것은 Git이 아닌 msys의 한계입니다. 자세한 내용은 https://github.com/msysgit/git/pull/110 에서 확인할 수 있습니다.

당신은 다른 힘내 Windows에서 클라이언트 또는 집합을 사용하여이 문제를 회피 할 수 있습니다 core.longpathstrue다른 답변에서 설명한다.

git config --system core.longpaths true

Git은 스크립트와 컴파일 된 코드의 조합으로 빌드됩니다. 위의 변경으로 일부 스크립트가 실패 할 수 있습니다. 이것이 core.longpaths가 기본적으로 활성화되지 않는 이유입니다.

https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file 의 Windows 설명서에 몇 가지 추가 정보가 있습니다.

Windows 10 버전 1607부터 MAX_PATH 제한이 일반적인 Win32 파일 및 디렉터리 기능에서 제거되었습니다. 그러나 새로운 동작을 선택해야합니다.

레지스트리 키를 사용하면 새로운 긴 경로 동작을 활성화하거나 비활성화 할 수 있습니다. 긴 경로 동작을 사용하려면 HKLM \ SYSTEM \ CurrentControlSet \ Control \ FileSystem LongPathsEnabled (유형 : REG_DWORD)에서 레지스트리 키를 설정하십시오.


명령을 실행할 수 있어야합니다.

git config --system core.longpaths true

또는 지원되는 Git 버전을 사용하는 경우 Git 구성 파일 중 하나에 수동으로 추가하여이 기능을 켜십시오. 1.9.0 이후로 보입니다.


도움이 될 수 있습니다.

git config core.longpaths true

기본 설명 :이 답변은 이러한 설정이 전역 시스템 (모든 프로젝트에 적용되므로 피 --system하거나 --global태그 지정) 구성에 적용하지 말 것을 제안 합니다. 이 명령은 현재 프로젝트에만 국한되어 문제를 해결합니다.


.gitconfig 생성 및 추가

[core]
longpaths = true

프로젝트 위치 (확실하지 않음) 및 전역 위치에 파일을 만들 수 있습니다. 제 경우에는 위치가 C:\Users\{name}\입니다.


더 나은 솔루션은 Git에서 longpath 매개 변수를 활성화하는 것입니다.

git config --system core.longpaths true

그러나 작동하는 해결 방법은 Git에서 node_modules 폴더를 제거하는 것입니다.

$ git rm -r --cached node_modules
$ vi .gitignore

.gitignore 파일의 새 행에 node_modules를 추가하십시오. 이 작업을 수행 한 후 수정 사항을 푸시합니다.

$ git add .gitignore
$ git commit -m "node_modules removed"
$ git push

따라야 할 단계 :

  1. 관리자 권한 으로 Git Bash 실행
  2. 실행 명령 git config --system core.longpaths true

git config 여기 에 대해 자세히 알아 보십시오 .


To be entirely sure that it takes effect immediately after the repository is initialized, but before the remote history is fetched or any files checked out, it is safer to use it this way:

git clone -c core.longpaths=true <repo-url>

-c key=value

Set a configuration variable in the newly-created repository; this takes effect immediately after the repository is initialized, but before the remote history is fetched or any files checked out. The key is in the same format as expected by git-config1 (e.g., core.eol=true). If multiple values are given for the same key, each value will be written to the config file. This makes it safe, for example, to add additional fetch refspecs to the origin remote.

More info


Executing git config --system core.longpaths true thrown an error to me:

"error: could not lock config file C:\Program Files (x86)\Git\mingw32/etc/gitconfig: Permission denied"

Fixed with executing the command at the global level:

git config --global core.longpaths true

You could also try to enable long file paths.

If you run Windows 10 Home Edition you could change your Registry to enable long paths.

Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem in regedit and then set LongPathsEnabled to 1.

If you have Windows 10 Pro or Enterprise you could also use Local Group Policies.

Go to Computer ConfigurationAdministrative TemplatesSystemFilesystem in gpedit.msc, open Enable Win32 long paths and set it to Enabled.


Move repository to root of your drive (temporary fix)

You can try to temporarily move the local repository (the entire folder) to the root of your drive or as close to the root as possible.

Since the path is smaller at the root of the drive, it sometimes fixes the issues.

On Windows, I'd move this to C:\ or another drive's root.


I had this error too, but in my case the cause was using an outdated version of npm, v1.4.28.

Updating to npm v3 followed by

rm -rf node_modules
npm -i

worked for me. npm issue 2697 has details of the "maximally flat" folder structure included in npm v3 (released 2015-06-25).


If you are working with your encrypted partition, consider moving the folder to an unencrypted partition, for example a /tmp, running git pull, and then moving back.

참고URL : https://stackoverflow.com/questions/22575662/filename-too-long-in-git-for-windows

반응형