Home > Back-end >  What is the point of using gitattributes file?
What is the point of using gitattributes file?

Time:09-27

I'm trying to read the docs but I don't understand. Can somebody explain me in simple words what the gitattributes file does?

CodePudding user response:

It defines the type (text, binary) of files defined by wildcard patterns (e.g. *.txt) and additional attributes, such as how to merge those files or if their line endings should be normalized.

For example you might have a .gitattributes file:

*.txt text
*.sh  text eol=lf    # force LF newlines on GNU Linux shell scripts
*.bat text eol=crlf  # force CRLF newlines on Windows batch files
*.jpg -text          # JPG files are not text
*.png -diff          # PNG files cannot be diffed
*.gif -text -diff -merge # GIF files are not text, cannot be diffed and cannot be merged
*.ogg binary         # equivalent to -text -diff -merge

Full documentation at https://git-scm.com/docs/gitattributes

  • Related