.gitattributes не соблюдается в большинстве ОС Windows

Итак, я попытался добавить файл .gitattributes в репозитории своих проектов, но столкнулся с проблемой, когда файл не соблюдается некоторыми из моих одноранговых компьютеров с Windows 10. Я пытался посмотреть на Git pull в Windows (клиент git smc) не учитывает eol=lf .gitattributes и многие другие сообщения безрезультатно, поскольку это не соответствует опыту, который я вижу. Я бы ожидал, что с учетом этого файла .gitattributes весь текст останется как LF, но это не так. ОС Windows активно конвертирует файлы в git add (все они прошли git add --renormalize .) в CRLF. Точное предупреждение: warning: LF will be replaced by CRLF in Callflows/ors_PostCreateOrsIssue.callflow. The file will have its original line endings in your working directory.

Чтобы еще больше запутать, пара ОС Windows моих сверстников работает, как и ожидалось, где соблюдаются LF и .gitattributes.

Гитатрибуты:

# Setting a default value and trusting git to do correctly determine files
*               text eol=LF

# Java sources
*.java          text diff=java
*.gradle        text diff=java
*.gradle.kts    text diff=java

# These files are text and should be normalized (Convert crlf => lf)
*.css           text diff=css
*.df            text
*.htm           text diff=html
*.html          text diff=html
*.js            text
*.jsp           text
*.jspf          text
*.jspx          text
*.properties    text
*.tld           text
*.tag           text
*.tagx          text
*.xml           text
*.grxml         text
*.callflow      text
*.json          text

# These files are binary and should be left untouched
# (binary is a macro for -text -diff)
*.class         binary
*.dll           binary
*.ear           binary
*.jar           binary
*.so            binary
*.war           binary
*.jks           binary
*.wav           binary
*.vox           binary
*.gram          binary

Вот рабочая установка с моей машины.

  • git --version: 2.18.0.окна.1
  • глобальная конфигурация git, полученная с помощью git config -l.
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
rebase.autosquash=true
http.sslcainfo=C:/Program Files/Git/asdf/ssl/certs/ca-bundle.crt
http.sslbackend=openssl
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
user.name=asdf
[email protected]
difftool.sourcetree.cmd='' "$LOCAL" "$REMOTE"
mergetool.sourcetree.cmd=''
mergetool.sourcetree.trustexitcode=true

Настройка от партнера, где он НЕ работает:

  • git --version: 2.18.0.окна.1
  • git config -l:
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
rebase.autosquash=true
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
http.sslbackend=openssl
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
credential.helper=manager
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
filter.lfs.clean=git-lfs clean -- %f

Любая помощь будет принята с благодарностью!


person aspark    schedule 20.10.2020    source источник


Ответы (1)


Вы неправильно настроили файл .gitattributes. Атрибут eol=lf, а не eol=LF. Этот параметр чувствителен к регистру, как и большинство параметров Git, и при указании LF этот атрибут не устанавливается. Поскольку он не установлен, а ваша версия Git настроена на core.autocrlf=true, ваши файлы извлекаются как CRLF.

Если вы это исправите, все должно работать правильно.

person bk2204    schedule 20.10.2020
comment
Попался, это имеет смысл! Я попробую это утром. По какой причине это будет работать на машине одного человека, где у них также есть core.autocrlf=true? - person aspark; 21.10.2020
comment
Это сообщение появляется только в том случае, если ваш редактор пишет окончания LF и ожидается CRLF, поэтому, возможно, их редактор настроен по-другому. - person bk2204; 22.10.2020