Git LFS and .gitattributes

Andrea Alicino
3 min readJan 17, 2024

Git Large File Storage (Git LFS) is an extension to Git that allows large files to be managed efficiently within a Git repository. Combined with the .gitattributes file, it provides advanced control over Git’s behavior concerning specific files or paths within the project.

What is Git LFS, and why do you use it?

Git is a powerful distributed version control system, but it can have limitations in handling large files such as images, videos, or other binary data. Git LFS solves this problem by storing the binary files in an external storage system and keeping only the metadata in the main repository.

The .gitattributes file:

The .gitattributes file plays a crucial role in configuring Git behavior. It can be used to specify attributes such as file types to be handled by Git LFS, font normalization, and merge conflict handling.

Here are some examples of configuration in the .gitattributes file:

example of .gitattributes file

How to use Git LFS:

1. Install Git LFS:
Before using Git LFS, you need to install the extension. Run the following command in the terminal:

2. Select the file types you want to manage with Git LFS:
You can specify the file types you want to manage with Git LFS in the .gitattributes file. For example, to manage files with the extension .mp4, add the following line:

3. Add and commit the file .gitattributes:
After configuring the file .gitattributes, be sure to add and commit it to the repository:

4. Adding and committing files with Git LFS:

Now, you can add and commit large files as you usually do with Git. Git LFS will automatically take care of transferring the binary files.

5. Push and Pull:

Push and pull operations are now handled efficiently by Git LFS. You can perform the following operations typically:

Be sure to document and share .gitattributes with your team members to ensure consistency in file management in the repository. By integrating Git LFS and .gitattributes, you gain advanced and efficient control over managing large files in your Git project.

See you in the next article🚀.

--

--

Andrea Alicino

Game Developer Unreal Engine/Unity. Computer science graduate. Seeking new opportunities.