![]() |
VOOZH | about |
Git LFS (Large File Storage) extends Git to handle large files efficiently by storing them outside the main repository and using lightweight pointers.
Git LFS manages large files by storing them externally and using pointer files within the Git repository.
In order to use Git LFS, first, we need to install it on our system. We can use the following command to do so.
sudo apt-get install git-lfsNow on the repository where we want to use Git-LFS, there we have to set up that.
Step 1: Run the command on the repository.
git lfs install It will initialize the LFS in the repository and will update the Git Hooks.
Step 2: Run the below command as listed:
git lfs track "*.jpg" This will tell git lfs to handle the jpg files, in case you want any other file, then you can specify that particular extension.
Step 3: As the configuration that is done on Step 2, is stored in the .gitattributes file, so we will add it for commit using the following command
git add .gitattributes Step 4: After this, create a new branch, add the large files, and push the branch to the remote repository.
Tip: If you don't know how to set up a remote branch and push code to it, then go through Git tutorial
Step 5: Now let us clone the repository from the remote.
Step 6: After cloning if we look at the size of the cloned repository and the original repository we can see that there is a big difference between their sizes.
The original Repository is as follows:
Cloned Repository is as follows:
Step 7: When you switch to the branch containing large files, Git LFS downloads the actual files from the remote server.
Here aer some common use cases: