Как настроить git, чтобы не возиться с новой строкой как в Windows, так и в LinuxLinux

Ответить Пред. темаСлед. тема
Anonymous
 Как настроить git, чтобы не возиться с новой строкой как в Windows, так и в Linux

Сообщение Anonymous »

Я столкнулся с некоторой проблемой при использовании проекта, отслеживаемого git, как в Windows, так и в Linux. Как было предложено в других вопросах по Windows, у меня есть

Код: Выделить всё

core.autocrlf=false
core.eol=
В Linux у меня есть настройки по умолчанию

Код: Выделить всё

core.autocrlf=
core.eol=
это мои .gitattributes, используемые в проекте

Код: Выделить всё

#general rule - ignore eol
* -text

#src
*.c     text diff=cpp
*.cc    text diff=cpp
*.cxx   text diff=cpp
*.cpp   text diff=cpp
*.cpi   text diff=cpp
*.c++   text diff=cpp
*.hpp   text diff=cpp
*.h     text diff=cpp
*.h++   text diff=cpp
*.hh    text diff=cpp
*.CPP   text diff=cpp
*.HPP   text diff=cpp
*.cs    text eol=crlf

# Unix files (LF)
*.sh            text eol=lf
Makefile        text eol=lf
makefile        text eol=lf
MAKEFILE        text eol=lf
make*           text eol=lf

# Windows files (CRLF)

*.sln    text eol=crlf
*.csproj text eol=crlf
*.suo    text eol=crlf
*.vbproj text eol=crlf
*.bat    text eol=crlf
*.vcxproj    text eol=crlf
*.vcproj     text eol=crlf
*.dbproj     text eol=crlf
*.fsproj     text eol=crlf
*.lsproj     text eol=crlf
*.wixproj    text eol=crlf
*.modelproj  text eol=crlf
*.sqlproj    text eol=crlf
*.wwaproj    text eol=crlf

*.xproj      text eol=crlf
*.props      text eol=crlf
*.filters    text eol=crlf
*.vcxitems   text eol=crlf

# common binary files
*.png binary
*.jpg binary
*.gif binary
*.com binary
*.exe binary
*.out binary
*.dll binary
*.a binary
*.lo binary
*.so binary
*.lai   binary
*.la    binary
*.slo binary
*.lib binary
*.class binary
*.dylib binary

# Precompiled Headers
*.gch   binary
*.pch   binary

# Ignoring whitespaces changes on edits
*.c -whitespace
*.cs -whitespace
*.cpp -whitespace
*.h -whitespace
*.hpp -whitespace

# Git LFS for big files
*.dll filter=lfs diff=lfs merge=lfs -text
*.pdb filter=lfs diff=lfs merge=lfs -text

# customized merge strategy for configuration files
.config merge=ours
*.user merge=ours

### From here JAVA ###

*.properties    text auto

# Unix (LF)

*.xml       text
*.java          text diff=java
*.kt            text diff=kotlin
*.groovy        text diff=java
*.scala         text diff=java
*.gradle        text diff=java
*.gradle.kts    text diff=kotlin

# config file merge strategy
*.iml merge=ours

# Ignores whitespace changes
*.java -whitespace

# Git LFS for big files
*.[jew]ar filter=lfs diff=lfs merge=lfs -text

# Common build-tool wrapper scripts ('.cmd' versions are handled by 'Common.gitattributes')
mvnw            text eol=lf
gradlew         text eol=lf
# Apply override to all files in the directory
*.md linguist-detectable

# Other files handled as text
*.txt       text auto
*.json      text eol=lf
*.yml       text eol=lf
*.yaml      text eol=lf
.git*       text
*.html      text
*.htm       text eol=crlf
*.css           text diff=css
*.scss          text diff=css
*.js            text
*.jsp           text
*.jspf          text
*.jspx          text
*.properties    text
*.tld           text
*.tag           text
*.tagx          text
и это мой .editorconfig (но я не думаю, что он используется в Windows, поскольку я использую VS2015)

Код: Выделить всё

root = true

[*]
#end_of_line = lf # commented out not to conflict with git
charset = utf-8
insert_final_newline = true

# Makefile using tab
[{Makefile,makefile,MAKEFILE,app.mak,lib.mak}]
indent_style = tab
trim_trailing_whitespace = true

[*.bat]
end_of_line = crlf

[*.{sh}]
end_of_line = lf

[*.{c,h,cpp,hpp,java,php,js,json,sh}]
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
max_line_length = 120
Я обнаружил, что в Linux также есть такие файлы, как project.sln (решение для визуальной студии) git diff | cat -v сообщает о преобразовании новой строки (^M удаляется после строк).
Кроме того, все остальные файлы сообщаются как измененные (единственными отличиями являются новые строки).< /p>
Как избежать сообщения Linux о «ложных» изменениях?
Что я упускаю?

Подробнее здесь: https://stackoverflow.com/questions/791 ... -and-linux
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Git clone git@github.com:kortina/dotfiles.git
    Anonymous » » в форуме Linux
    0 Ответы
    60 Просмотры
    Последнее сообщение Anonymous
  • Каков наилучший способ запретить пользователю приложения возиться с файлами приложения?
    Anonymous » » в форуме Linux
    0 Ответы
    11 Просмотры
    Последнее сообщение Anonymous
  • Разрешение файла конфигурации git потеряно после `git Remote set-url origin https://`
    Гость » » в форуме Linux
    0 Ответы
    78 Просмотры
    Последнее сообщение Гость
  • Невозможно создать локальный Git для проекта — используется Git библиотеки классов?
    Anonymous » » в форуме C#
    0 Ответы
    34 Просмотры
    Последнее сообщение Anonymous
  • Как исправить ошибку setuptools_scm._file_finders.git со списком git-файлов?
    Anonymous » » в форуме Python
    0 Ответы
    29 Просмотры
    Последнее сообщение Anonymous

Вернуться в «Linux»