Skip to content

Commit e28eae3

Browse files
tboegigitster
authored andcommitted
gitattributes: Document the unified "auto" handling
Update the documentation about text=auto: text=auto now follows the core.autocrlf handling when files are not normalized in the repository. For a cross platform project recommend the usage of attributes for line-ending conversions. Signed-off-by: Torsten Bögershausen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5cb0d5a commit e28eae3

File tree

1 file changed

+24
-34
lines changed

1 file changed

+24
-34
lines changed

Documentation/gitattributes.txt

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -182,23 +182,6 @@ While Git normally leaves file contents alone, it can be configured to
182182
normalize line endings to LF in the repository and, optionally, to
183183
convert them to CRLF when files are checked out.
184184

185-
Here is an example that will make Git normalize .txt, .vcproj and .sh
186-
files, ensure that .vcproj files have CRLF and .sh files have LF in
187-
the working directory, and prevent .jpg files from being normalized
188-
regardless of their content.
189-
190-
------------------------
191-
* text=auto
192-
*.txt text
193-
*.vcproj text eol=crlf
194-
*.sh text eol=lf
195-
*.jpg -text
196-
------------------------
197-
198-
Other source code management systems normalize all text files in their
199-
repositories, and there are two ways to enable similar automatic
200-
normalization in Git.
201-
202185
If you simply want to have CRLF line endings in your working directory
203186
regardless of the repository you are working with, you can set the
204187
config variable "core.autocrlf" without using any attributes.
@@ -208,35 +191,42 @@ config variable "core.autocrlf" without using any attributes.
208191
autocrlf = true
209192
------------------------
210193

211-
This does not force normalization of all text files, but does ensure
194+
This does not force normalization of text files, but does ensure
212195
that text files that you introduce to the repository have their line
213196
endings normalized to LF when they are added, and that files that are
214197
already normalized in the repository stay normalized.
215198

216-
If you want to interoperate with a source code management system that
217-
enforces end-of-line normalization, or you simply want all text files
218-
in your repository to be normalized, you should instead set the `text`
219-
attribute to "auto" for _all_ files.
199+
If you want to ensure that text files that any contributor introduces to
200+
the repository have their line endings normalized, you can set the
201+
`text` attribute to "auto" for _all_ files.
220202

221203
------------------------
222204
* text=auto
223205
------------------------
224206

225-
This ensures that all files that Git considers to be text will have
226-
normalized (LF) line endings in the repository. The `core.eol`
227-
configuration variable controls which line endings Git will use for
228-
normalized files in your working directory; the default is to use the
229-
native line ending for your platform, or CRLF if `core.autocrlf` is
230-
set.
207+
The attributes allow a fine-grained control, how the line endings
208+
are converted.
209+
Here is an example that will make Git normalize .txt, .vcproj and .sh
210+
files, ensure that .vcproj files have CRLF and .sh files have LF in
211+
the working directory, and prevent .jpg files from being normalized
212+
regardless of their content.
213+
214+
------------------------
215+
* text=auto
216+
*.txt text
217+
*.vcproj text eol=crlf
218+
*.sh text eol=lf
219+
*.jpg -text
220+
------------------------
221+
222+
NOTE: When `text=auto` conversion is enabled in a cross-platform
223+
project using push and pull to a central repository the text files
224+
containing CRLFs should be normalized.
231225

232-
NOTE: When `text=auto` normalization is enabled in an existing
233-
repository, any text files containing CRLFs should be normalized. If
234-
they are not they will be normalized the next time someone tries to
235-
change them, causing unfortunate misattribution. From a clean working
236-
directory:
226+
From a clean working directory:
237227

238228
-------------------------------------------------
239-
$ echo "* text=auto" >>.gitattributes
229+
$ echo "* text=auto" >.gitattributes
240230
$ rm .git/index # Remove the index to force Git to
241231
$ git reset # re-scan the working directory
242232
$ git status # Show files that will be normalized

0 commit comments

Comments
 (0)