簡體   English   中英

無法擺脫git line結尾問題

[英]Unable to get rid of git line ending issues

在當前項目中,我們有多個用戶在Windows,OSX和Ubuntu等多台計算機上編輯資源庫。 我嘗試了各種設置以使行尾正常化,但是我不斷收到通知,說明倉庫中的隨機文件的行尾會發生變化。

首先,我的存儲庫中有以下git屬性文件:

# These settings are for any web project

# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
* text=auto

#
# The above will handle all files NOT found below
#

# Documents
*.doc      diff=astextplain eol=lf
*.DOC      diff=astextplain eol=lf
*.docx     diff=astextplain eol=lf
*.DOCX     diff=astextplain eol=lf
*.dot      diff=astextplain eol=lf
*.DOT      diff=astextplain eol=lf
*.pdf      diff=astextplain eol=lf
*.PDF      diff=astextplain eol=lf
*.rtf      diff=astextplain eol=lf
*.RTF      diff=astextplain eol=lf
*.md       text             eol=lf
*.adoc     text             eol=lf
*.textile  text             eol=lf
*.mustache text             eol=lf
*.csv      text             eol=lf
*.tab      text             eol=lf
*.tsv      text             eol=lf
*.sql      text             eol=lf

# Graphics
*.png  binary
*.jpg  binary
*.jpeg binary
*.gif  binary
*.ico  binary
*.svg  text eol=lf

# These files are text and should be normalized (Convert crlf => lf)
*.md       text eol=lf
*.adoc     text eol=lf
*.textile  text eol=lf
*.mustache text eol=lf
*.csv      text eol=lf
*.tab      text eol=lf
*.tsv      text eol=lf
*.php      text eol=lf
*.css      text eol=lf
*.js       text eol=lf
*.json     text eol=lf
*.htm      text eol=lf
*.html     text eol=lf
*.xml      text eol=lf
*.txt      text eol=lf
*.ini      text eol=lf
*.inc      text eol=lf
*.pl       text eol=lf
*.rb       text eol=lf
*.py       text eol=lf
*.scm      text eol=lf
*.sql      text eol=lf
.htaccess  text eol=lf

# These files are binary and should be left untouched
# (binary is a macro for -text -diff)
*.mov  binary
*.mp4  binary
*.mp3  binary
*.flv  binary
*.fla  binary
*.swf  binary
*.gz   binary
*.zip  binary
*.7z   binary
*.ttf  binary
*.pyc  binary

並且我已經在計算機(Windows,OSX和Linux)上設置了這些git設置:

git config --global core.eol lf
git config --global core.autocrlf false

但是我會間歇性地從git(cli)中收到通知,當我從開發服務器中提取更改時(在一天結束時更新了測試中的更改),我得到了一條消息,指出在提交時CRLF將轉換為LF。 。

盡管最近,我注意到我和我的同類(在Windows上)並沒有經常收到這些消息。 但是,mac / linux上的其他人似乎在每次重新簽出遠程分支時都可以得到它們(即使在刪除本地版本之后也是如此)。 跑步時

git checkout -b develop -t origin/develop

他們應該有一個完全干凈的目錄,它們將包含1-6個文件,這些文件顯示更改。 只是行尾。 而且,無論我們做什么,我們都不能在沒有承諾的情況下擺脫它們。 即使他們投入了精力並直接將其推送回開發,提取后的另一個開發人員也會拉出一個新的development分支(在刪除本地development分支之后)將獲得另一個隨機文件,該文件指出其CRLF結尾將轉換為LF。

您可能想看看我的一個問題,也處理行尾

歸一化后的Git行結尾

我堅持答案是通過將以下內容添加到您的.gitattributes中來停止git進行任何規范化

* -text
* whitespace=cr-at-eol

然后,這使您可以控制-您要做的就是將每個文件都設置為所需的行尾,一次性操作。 行尾的神奇轉換是在不同操作系統上的編輯者只能處理帶有其本機行尾(IMNSHO)的文件的時代的一種保留。 如今,這僅是使用記事本進行編碼的問題:-)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM