2014-01-23 45 views

回答

2

它基本上禁用eol根據documentation

有時候你需要重寫一個屬性的設置爲 路徑未指定狀態。這可以通過列出前綴爲感嘆號的 屬性的名稱來完成!

eol執行以下操作:

該屬性設置在 工作 目錄中使用的特定行結束樣式。它可以在沒有任何內容檢查的情況下啓用行結束標準化,從而有效地設置文本屬性。

1

短版:

如果Git的決定內容是文本,它的行結束標準化爲LF上籤。 恢復某些嵌套的.gitattributes文件中的任何顯式eol設置。

參見man gitattributes

Each line in gitattributes file is of form: 

     pattern attr1 attr2 ... 

    Sometimes you would need to override an setting of an attribute for a path to 
    Unspecified state. This can be done by listing the name of the attribute 
    prefixed with an exclamation point !. 

    text 
     This attribute enables and controls end-of-line normalization. When a text 
     file is normalized, its line endings are converted to LF in the 
     repository. To control what line ending style is used in the working 
     directory, use the eol attribute for a single file and the core.eol 
     configuration variable for all text files. 

     Set to string value "auto" 
      When text is set to "auto", the path is marked for automatic 
      end-of-line normalization. If Git decides that the content is text, 
      its line endings are normalized to LF on checkin. 

    eol 
     This attribute sets a specific line-ending style to be used in the working 
     directory. It enables end-of-line normalization without any content 
     checks, effectively setting the text attribute. 
3
* text=auto !eol 

意味着:

  • 沒有EOL(線結束)轉換爲將二進制文件來執行。
  • 爲文本文件,EOLS都在檢查出該文件轉換爲依賴於操作系統的EOL(轉換到LF Unix和CR + LF適用於Windows)和,而在檢查與LF替換。
+0

爲什麼** NO ** eol轉換? ('!'是爲了否定否定。) – michas

+0

@michas我不確定你在這裏有什麼疑問 - 上面的'!eol'將__only__應用於__not__文本文件。 – devnull

+0

@devnull你如何看待'!eol'適用於**不是**文本的文件?它與'*'通配符在同一行,所以對我來說意味着它將刪除'eol'的顯式設置,但不確定'eol'的默認設置是什麼。這將適用於所有文件,對不對?你的答案很混亂。 –

12

GIT中有2個屬性是處理結束行:

  1. 文本

文件說:

該屬性啓用並控制行結束標準化。當一個文本文件是標準化的,它的行結束轉換爲LF在倉庫中

這實際上意味着,當你承諾回購,它會轉換行結束到LF

  • EOL
  • 文件說:

    該屬性將在工作目錄中使用的特定行結束樣式。它可以在沒有任何內容檢查的情況下啓用行結束標準化,從而有效地設置文本屬性。

    因此,儘管文本屬性影響的文件將如何看起來像回購,eol影響文件看起來像在工作目錄。現在

    ,屬性可具有4種狀態:

    組沒有值
    例如:* text

    未設置
    例如:* -text

    組具有特定值
    例如:* text=auto

    unspeci田間
    例如:* !text

    所以,* text=auto !eol含義:

    所有文件屬性文字設置爲auto和EOL屬性不明。閱讀文檔,我們發現text = auto意味着你讓git決定一個文件是否爲文本,如果是的話,它會對它進行標準化(將回車中的行尾設置爲LF)。

    !eol意味着屬性EOL設置爲未指定明確。在這種情況下,它與完全不指定它相同,指示Git查看core.eol配置設置,以瞭解如何處理工作目錄中的行尾。請注意:

    core.eol配置變量控制Git將用於工作目錄中規範化文件的行結束符;默認情況下,將使用以您的平臺結束的本地行,如果core.autocrlf已設置,則使用CRLF。

    但是你可以使用EOL在下面這樣的情況:

    * text=auto eol=CRLF 
    test.txt !eol 
    

    基本上覆蓋了EOL屬性從CRLF不明爲test.txt的。這意味着對於除test.txt之外的所有文件,Git會在檢出EOL時將其轉換爲CRLF,但不會對test.txt執行任何操作。線(合理猜測)的

    相關問題