There are a lot of articles in the web saying it is a good practice to place binary files under LFS. So, .gitattributes
file will look like this:
## Fonts
*.otf filter=lfs diff=lfs merge=lfs -text
*.OTF filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.TTF filter=lfs diff=lfs merge=lfs -text
Note that all the entries contain -text
which tells git to not treat these files as text files and treat them as binary.
Now, let's say I want to track some text files with extension *.yaml
as LFS because they are very large but still text based. Should I create entries in the same way as for binary ones or should I omit -text
like this?
*.yaml filter=lfs diff=lfs merge=lfs
*.YAML filter=lfs diff=lfs merge=lfs
gitattributes file allows you to specify the files and paths attributes that should be used by git when performing git actions, such as git commit , etc. In other words git automatically saves the file according to the attributes specified, every time a file is created or saved.
You should use Git LFS if you have large files or binary files to store in Git repositories. That's because Git is decentralized. So, every developer has the full change history on their computer.
Git Large File Storage Git LFS takes advantage of this centralized pattern. Large files are stored in the cloud, and these files are referenced via pointers in local copies of the repo. When a clone or pull occurs, the appropriate version of the file is downloaded from the remote.
Yes, you always want to exclude the text
attribute for files using Git LFS. The reason is that you don't want the pointer files stored in the repository to be subject to line-ending conversions or encoding changes, since that would make them invalid, nor do you want that for the large files, since that makes the hash change and therefore the underlying pointer file change as well. The text
attribute controls these aspects, and therefore it should be disabled.
FYI -text means unset the text attribute i.e.
# Treat *.otf as **not** text
*.otf filter=lfs diff=lfs merge=lfs -text
# Treat *.otf as text
*.otf filter=lfs diff=lfs merge=lfs text
Leaving -text out will then use what ever default you have set in your .gitattributes file. So probably better to leave -text imo
See https://git-scm.com/docs/gitattributes#_end_of_line_conversion
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With