{"id":8007,"date":"2024-11-26T05:02:29","date_gmt":"2024-11-26T05:02:29","guid":{"rendered":"https:\/\/studysection.com\/blog\/?p=8007"},"modified":"2024-11-26T05:26:40","modified_gmt":"2024-11-26T05:26:40","slug":"why-do-we-need-git-lfs","status":"publish","type":"post","link":"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/","title":{"rendered":"Why do we need Git LFS?"},"content":{"rendered":"<p>Git LFS (Git Large File Storage) is an extension for Git designed specifically to handle large files. Standard Git is highly efficient for managing and versioning source code, but it struggles with large binary files or assets like high-resolution images, videos, datasets, and compiled assets. Git LFS offers a workaround by keeping big files off of the main Git repository, which keeps the main repository quick and light.<\/p>\n<p><strong>Why Do We Need Git LFS (Git Large File Storage)?<\/strong><br \/>\nWhen using Git to manage projects with large or frequently changing files, you may run into several challenges:<\/p>\n<ol>\n<li><strong>Repository Size:<\/strong> Git stores a complete history of all changes, so committing large files repeatedly (like modified images or datasets) can balloon the repository size. This makes cloning, fetching, and pulling take significantly longer.<\/li>\n<li><strong>Slow Performance:<\/strong> With many large files, Git operations become slower. Actions like cloning and pushing are impacted as Git has to handle all historical versions of these files.<\/li>\n<li><strong>Binary Files and Merging:<\/strong> Git is optimized for text-based files, making it great for source code but less effective for binary files like images, audio, or video. Binary files can&#8217;t be efficiently compared (diffed) or merged by Git, so handling them in version control becomes cumbersome.<\/li>\n<li><strong>Storage Limits on Platforms:<\/strong> Platforms like GitHub, <a href=\"https:\/\/studysection.com\/blog\/git-basic-commands\/\">GitLab<\/a>, and Bitbucket often have repository size limits or charge extra for larger repos. Using Git LFS, you can keep the main repo size smaller and avoid these limitations.<\/li>\n<\/ol>\n<p><strong>How Git LFS Works<\/strong><\/p>\n<p>Instead of storing the entire large file in the repository, Git LFS replaces the file with a small &#8220;pointer file&#8221; that references the large file. The actual large file is stored separately in a specialized LFS storage location. Here\u2019s how it works in practice:<\/p>\n<ul>\n<li>Large files tracked by Git LFS are stored on a different Git LFS server, and Git replaces them with a reference in the repository.<\/li>\n<li>When someone clones or pulls the repository, Git LFS automatically fetches the large files separately from the main Git data, keeping operations fast and efficient.<\/li>\n<\/ul>\n<p><strong>Example: Setting Up Git LFS on Ubuntu<\/strong><\/p>\n<p><strong>1. Install Git LFS<\/strong><br \/>\nFirst, use the package manager to install Git LFS:<br \/>\n<code>:~$ sudo apt update<br \/>\n:~$ sudo apt install git-lfs<\/code><\/p>\n<p><strong>2. Initialize Git LFS in Your Project<\/strong><br \/>\nYou must initialize Git LFS in your project when it has been installed:<\/p>\n<p><code> :~$ git lfs install<\/code><\/p>\n<p>This command configures your repository for Git LFS tracking. This command should only be used once per system.<\/p>\n<p><strong>3. Track Specific File Types with Git LFS<\/strong><br \/>\nUse git lfs track to specify the types of large files you want to store with Git LFS. For example:<\/p>\n<p><code>:~$ git lfs track \"*.psd\" # Track Photoshop files<br \/>\n:~$ git lfs track \"*.mp4\" # Track video files<br \/>\n:~$ git lfs track \"*.zip\" # Track zip files<\/code><\/p>\n<p>This command creates or updates a .gitattributes file in the root of your project. The .gitattributes file contains instructions for Git LFS on which files to track.<\/p>\n<p><strong>4. Add, Commit, and Push Files<\/strong><br \/>\nNow, add, commit, and push your files as usual. Git LFS will handle the large files according to the patterns defined in .gitattributes.<\/p>\n<p><code>:~$ git add .  # Stage all changes, including large files<br \/>\n:~$ git commit -m \"Add large files with Git LFS\"  # Commit with a message<br \/>\n:~$ git push origin master\/main  # Push to the remote repository named \u201cmain or master\u201d<\/code><\/p>\n<p><strong>5. Clone and Pull Large Files<\/strong><br \/>\nWhen someone else clones the repository or pulls updates, Git LFS will automatically download the large files separately from the regular Git data. Ensure they have Git LFS installed on their system to get the actual content of large files instead of pointer files.<br \/>\n<code>:~$ git clone <\/code><\/p>\n<p><strong>When to Use Git LFS<\/strong><\/p>\n<p>Git LFS is ideal if your project includes:<\/p>\n<ul>\n<li>Large media files (e.g., high-resolution images, video files).<\/li>\n<li>Binary assets (e.g., compiled application files, executable binaries).<\/li>\n<li>Large datasets for data science or machine learning projects.<\/li>\n<li>Any file that changes frequently and doesn\u2019t work well with Git\u2019s standard diff and merge capabilities.<\/li>\n<\/ul>\n<p>By using Git LFS, you can avoid the limitations of standard Git for large files, enabling you to manage all your project assets more effectively.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Git LFS (Git Large File Storage) is an extension for Git designed specifically to handle large files. Standard Git is<\/p>\n","protected":false},"author":1,"featured_media":8009,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Why do we need Git LFS (Git Large File Storage)?<\/title>\n<meta name=\"description\" content=\"Git LFS (Git Large File Storage) is an extension for Git designed specifically to handle large files. Standard Git is highly efficient for...\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Why do we need Git LFS (Git Large File Storage)?\" \/>\n<meta property=\"og:description\" content=\"Git LFS (Git Large File Storage) is an extension for Git designed specifically to handle large files. Standard Git is highly efficient for...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog Posts on famous people, innovations and educational topics\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/studysection\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-26T05:02:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-26T05:26:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2024\/11\/Add-a-subheading-19.png\" \/>\n\t<meta property=\"og:image:width\" content=\"940\" \/>\n\t<meta property=\"og:image:height\" content=\"788\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"admin-studysection-blog\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@studysection\" \/>\n<meta name=\"twitter:site\" content=\"@studysection\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin-studysection-blog\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/\"},\"author\":{\"name\":\"admin-studysection-blog\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\"},\"headline\":\"Why do we need Git LFS?\",\"datePublished\":\"2024-11-26T05:02:29+00:00\",\"dateModified\":\"2024-11-26T05:26:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/\"},\"wordCount\":614,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"articleSection\":[\"Learn and Grow\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/\",\"url\":\"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/\",\"name\":\"Why do we need Git LFS (Git Large File Storage)?\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/#website\"},\"datePublished\":\"2024-11-26T05:02:29+00:00\",\"dateModified\":\"2024-11-26T05:26:40+00:00\",\"description\":\"Git LFS (Git Large File Storage) is an extension for Git designed specifically to handle large files. Standard Git is highly efficient for...\",\"breadcrumb\":{\"@id\":\"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/studysection.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Why do we need Git LFS?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/studysection.com\/blog\/#website\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"name\":\"Blog Posts on famous people, innovations and educational topics\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/studysection.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/studysection.com\/blog\/#organization\",\"name\":\"StudySection\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"contentUrl\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"width\":920,\"height\":440,\"caption\":\"StudySection\"},\"image\":{\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/studysection\",\"https:\/\/twitter.com\/studysection\",\"https:\/\/www.instagram.com\/study.section\/\",\"https:\/\/www.linkedin.com\/company\/studysection\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\",\"name\":\"admin-studysection-blog\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"caption\":\"admin-studysection-blog\"},\"url\":\"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Why do we need Git LFS (Git Large File Storage)?","description":"Git LFS (Git Large File Storage) is an extension for Git designed specifically to handle large files. Standard Git is highly efficient for...","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/","og_locale":"en_US","og_type":"article","og_title":"Why do we need Git LFS (Git Large File Storage)?","og_description":"Git LFS (Git Large File Storage) is an extension for Git designed specifically to handle large files. Standard Git is highly efficient for...","og_url":"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/","og_site_name":"Blog Posts on famous people, innovations and educational topics","article_publisher":"https:\/\/www.facebook.com\/studysection","article_published_time":"2024-11-26T05:02:29+00:00","article_modified_time":"2024-11-26T05:26:40+00:00","og_image":[{"width":940,"height":788,"url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2024\/11\/Add-a-subheading-19.png","type":"image\/png"}],"author":"admin-studysection-blog","twitter_card":"summary_large_image","twitter_creator":"@studysection","twitter_site":"@studysection","twitter_misc":{"Written by":"admin-studysection-blog","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/#article","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/"},"author":{"name":"admin-studysection-blog","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402"},"headline":"Why do we need Git LFS?","datePublished":"2024-11-26T05:02:29+00:00","dateModified":"2024-11-26T05:26:40+00:00","mainEntityOfPage":{"@id":"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/"},"wordCount":614,"commentCount":0,"publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"articleSection":["Learn and Grow"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/","url":"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/","name":"Why do we need Git LFS (Git Large File Storage)?","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/#website"},"datePublished":"2024-11-26T05:02:29+00:00","dateModified":"2024-11-26T05:26:40+00:00","description":"Git LFS (Git Large File Storage) is an extension for Git designed specifically to handle large files. Standard Git is highly efficient for...","breadcrumb":{"@id":"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/studysection.com\/blog\/why-do-we-need-git-lfs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/studysection.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Why do we need Git LFS?"}]},{"@type":"WebSite","@id":"https:\/\/studysection.com\/blog\/#website","url":"https:\/\/studysection.com\/blog\/","name":"Blog Posts on famous people, innovations and educational topics","description":"","publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/studysection.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/studysection.com\/blog\/#organization","name":"StudySection","url":"https:\/\/studysection.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","contentUrl":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","width":920,"height":440,"caption":"StudySection"},"image":{"@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/studysection","https:\/\/twitter.com\/studysection","https:\/\/www.instagram.com\/study.section\/","https:\/\/www.linkedin.com\/company\/studysection"]},{"@type":"Person","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402","name":"admin-studysection-blog","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","caption":"admin-studysection-blog"},"url":"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/"}]}},"views":129,"_links":{"self":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/8007"}],"collection":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/comments?post=8007"}],"version-history":[{"count":4,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/8007\/revisions"}],"predecessor-version":[{"id":8012,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/8007\/revisions\/8012"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media\/8009"}],"wp:attachment":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media?parent=8007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/categories?post=8007"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/tags?post=8007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}