Home Explore Blog CI



git

17th chunk of `Documentation/gitattributes.adoc`
4ee79129dc145e8fe327d8d41e0fadc2293cda3104855a090000000100000e78
 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, when set, also
sets or unsets a number of other attributes at the same time.  The
system knows a built-in macro attribute, `binary`:

------------
*.jpg binary
------------

Setting the "binary" attribute also unsets the "text" and "diff"
attributes as above.  Note that macro attributes can only be "Set",
though setting one might have the effect of setting or unsetting other
attributes or even returning other attributes to the "Unspecified"
state.


DEFINING MACRO ATTRIBUTES
-------------------------

Custom macro attributes can be defined only in top-level gitattributes
files (`$GIT_DIR/info/attributes`, the `.gitattributes` file at the
top level of the working tree, or the global or system-wide
gitattributes files), not in `.gitattributes` files in working tree
subdirectories.  The built-in macro attribute "binary" is equivalent
to:

------------
[attr]binary -diff -merge -text
------------

NOTES
-----

Git does not follow symbolic links when accessing a `.gitattributes`
file in the working tree. This keeps behavior consistent when the file
is accessed from the index or a tree versus from the filesystem.

EXAMPLES
--------

If you have these three `gitattributes` file:

----------------------------------------------------------------
(in $GIT_DIR/info/attributes)

a*	foo !bar -baz

(in .gitattributes)
abc	foo bar baz

(in t/.gitattributes)
ab*	merge=filfre
abc	-foo -bar
*.c	frotz
----------------------------------------------------------------

the attributes given to path `t/abc` are computed as follows:

1. By examining `t/.gitattributes` (which is in the same
   directory as the path in question), Git finds that the first
   line matches.  `merge` attribute is set.  It also finds that
   the second line matches, and attributes `foo` and `bar`
   are unset.

2. Then it examines `.gitattributes` (which is in the parent
   directory), and finds that the first line matches, but
   `t/.gitattributes` file already decided how `merge`, `foo`
   and `bar` attributes should be given to this path, so it
   leaves `foo` and `bar` unset.  Attribute `baz` is set.

3. Finally it examines `$GIT_DIR/info/attributes`.  This file
   is used to override the in-tree settings.  The first line is
   a match, and `foo` is set, `bar` is reverted to unspecified
   state, and `baz` is unset.

As the result, the attributes assignment to `t/abc` becomes:

----------------------------------------------------------------
foo	set to true
bar	unspecified
baz	set to false
merge	set to string value "filfre"
frotz	unspecified
----------------------------------------------------------------


SEE ALSO
--------
linkgit:git-check-attr[1].

GIT
---
Part of the linkgit:git[1] suite

Title: Git Attributes and Macro Attributes
Summary
Git attributes allow for customizing Git's behavior, and macro attributes provide a way to define a set of attributes that can be applied to files, making it easier to manage complex attribute settings, with options to set, unset, or override attributes in various gitattributes files.