Git репозиторий с файлами CRLF и LF?
У меня есть git-репозиторий, у которого окончание строк в файлах должно быть CRLF или LR для извлеченного файла в зависимости от конкретного файла. Например, я хочу, чтобы все файлы *.sh были извлечены с окончанием строки LR, а все файлы *.bat с CRLF.
Я пытался осуществить это безрезультатно, следующий мой .gitattributes
файл:
* text=auto
#
# Declare files that will always have CRLF line endings on checkout.
#
*.sh text eol=LF
#
# Declare files that will always have LF line endings on checkout.
#
*.bat text eol=CRLF
#
# Denote all files that are truly binary and should not be modified.
#
*.zip binary
*.tar binary
*.exe binary
*.dll binary
*/dropbear binary
*update-binary binary
Когда я открываю .sh
файл или .bat
файл оба конца строки являются CRLF. Что я делаю неправильно?
Примечание: я разрабатываю на компьютере под управлением Windows.
РЕДАКТИРОВАТЬ: системная, глобальная и локальная конфигурация
система:
core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true
Глобальный:
merge.tool=kdiff3
diff.guitool=kdiff3
core.editor="C:/Program Files (x86)/GitExtensions/GitExtensions.exe" fileeditor
core.autocrlf=true
credential.helper=!'C:\Users\XXXX\AppData\Roaming\GitCredStore\git-credential-winstore.exe'
user.name=xxxxx.xxxx
user.email=xxxx.xxxx@xxxxx.com
filter.lfs.clean=git-lfs clean %f
filter.lfs.smudge=git-lfs smudge %f
filter.lfs.required=true
push.default=matching
Местный:
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
remote.origin.url=https://github.com/XXXXXX/xxxxxx.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.v2.10.0.remote=origin
branch.v2.10.0.merge=refs/heads/v2.10.0
branch.v2.10.1.remote=origin
branch.v2.10.1.merge=refs/heads/v2.10.1
Также в документации GitHub говорится следующее:
При желании вы можете настроить способ, которым Git управляет окончаниями строк для каждого репозитория, путем настройки специального файла.gitattributes. Этот файл фиксируется в репозитории и переопределяет индивидуальный параметр core.autocrlf, обеспечивая согласованное поведение для всех пользователей, независимо от их настроек Git.
РЕДАКТИРОВАТЬ 2:
Если я установлю core.autocrlf
в false
и прокомментируйте все строки .gitattributes
тогда оба .sh
а также .bat
файлы открываются с окончанием строки LF.
1 ответ
eol
Значение атрибута, как и большинство Git, чувствительно к регистру. Ты хочешь:
*.sh eol=lf
*.bat eol=crlf