Home Explore Blog CI



git

16th chunk of `Documentation/gitattributes.adoc`
56ce89ad24028fffa9814ddf4c87125f84eac173ac8b9ea90000000100000a90

~~~~~~~~~~~~~~~~~~~~~~~~~~

`whitespace`
^^^^^^^^^^^^

The `core.whitespace` configuration variable allows you to define what
'diff' and 'apply' should consider whitespace errors for all paths in
the project (See linkgit:git-config[1]).  This attribute gives you finer
control per path.

Set::

	Notice all types of potential whitespace errors known to Git.
	The tab width is taken from the value of the `core.whitespace`
	configuration variable.

Unset::

	Do not notice anything as error.

Unspecified::

	Use the value of the `core.whitespace` configuration variable to
	decide what to notice as error.

String::

	Specify a comma separated list of common whitespace problems to
	notice in the same format as the `core.whitespace` configuration
	variable.


Creating an archive
~~~~~~~~~~~~~~~~~~~

`export-ignore`
^^^^^^^^^^^^^^^

Files and directories with the attribute `export-ignore` won't be added to
archive files.

`export-subst`
^^^^^^^^^^^^^^

If the attribute `export-subst` is set for a file then Git will expand
several placeholders when adding this file to an archive.  The
expansion depends on the availability of a commit ID, i.e., if
linkgit:git-archive[1] has been given a tree instead of a commit or a
tag then no replacement will be done.  The placeholders are the same
as those for the option `--pretty=format:` of linkgit:git-log[1],
except that they need to be wrapped like this: `$Format:PLACEHOLDERS$`
in the file.  E.g. the string `$Format:%H$` will be replaced by the
commit hash.  However, only one `%(describe)` placeholder is expanded
per archive to avoid denial-of-service attacks.


Packing objects
~~~~~~~~~~~~~~~

`delta`
^^^^^^^

Delta compression will not be attempted for blobs for paths with the
attribute `delta` set to false.


Viewing files in GUI tools
~~~~~~~~~~~~~~~~~~~~~~~~~~

`encoding`
^^^^^^^^^^

The value of this attribute specifies the character encoding that should
be used by GUI tools (e.g. linkgit:gitk[1] and linkgit:git-gui[1]) to
display the contents of the relevant file. Note that due to performance
considerations linkgit:gitk[1] does not use this attribute unless you
manually enable per-file encodings in its options.

If this attribute is not set or has an invalid value, the value of the
`gui.encoding` configuration variable is used instead
(See linkgit:git-config[1]).


USING MACRO ATTRIBUTES
----------------------

You do not want any end-of-line conversions applied to, nor textual diffs
produced for, any binary file you track.  You would need to specify e.g.

------------
*.jpg -text -diff
------------

but that may become cumbersome, when you have many attributes.  Using
macro attributes, you can define an attribute that,

Title: Git Attributes for Customizing Behavior
Summary
Git attributes allow for fine-grained control over various aspects of Git's behavior, including whitespace errors, archive creation, object packing, and file viewing in GUI tools, enabling customization of the Git experience for specific files and projects.