How to Handle Big Repositories With Git? Last Updated : 27 May, 2024 Comments Improve Suggest changes 1 Likes Like Report Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git relies on the basis of distributed development of software where more than one developer may have access to the source code of a specific application and can modify changes to it that may be seen by other developers. In this article, we will learn how to handle big repositories with Git. Table of Content 1. Using the shallow clone2. Using git-filter3. Cloning a single branch1. Using the shallow cloneThis is a comparatively fast solution where we pull down only the latest commits of the repo's history. Imagine I have a repository with 1 GB of data with more than 35000+ commits. If I choose full cloning this repository, it's general it will take a large amount of time, but if we choose to pull only the latest n commits it can reduce our time exponentially. To perform shallow cloning we need to add --depth command with our clone command git clone --depth [n] [url]Here n specifies number of latest n commitsurl specifies the remote url of the repository2. Using git-filterHere we can walk through the entire project history, modify, filter, or skip according to our necessity. This is generally used when we do have a large number of binary files and we need only some. To use git-filter we use the following command: git filter-branch --tree-filter 'rm -rf [path-to-asset]'path-to-asset signifies the path to binary asset in your repositoryAlthough powerful, it comes with its own shortcoming that whenever we do git-filter, it changes the ids of the commit which will further require recloning. Therefore required care of recloning must be taken while using git-filter 3. Cloning a single branchThis technique is useful when we do have multiple branches but we want to work with some of them. To clone a single branch, we can use the following command: git clone [url] --branch [branch_name] --single-branchurl specifies the remote url of the repositorybranch_name specifies the name of the branch you want to cloneHandling repositories with a large number of binary files: We can use submodules, i.e. repository inside another repository. The inside repository will contain all the binary files which will provide us modularity since it will keep parent code separately and if in the future we want to make changes in this sub-module it will not affect the parent code repository.We can use third-party extensions like Git LFS, a Git extension used to manage large files and binary files in a separate Git repository.We can use garbage collection git-gc which does turn several loose objects into a single file. Create Quiz Comment U unknwncdr878 Follow 1 Improve U unknwncdr878 Follow 1 Improve Article Tags : Web Technologies Git Explore Git IntroductionGit Introduction 5 min read Introduction to Github 5 min read An Ultimate Guide to Git and Github 12 min read What is Git? 6 min read What Is Gitlab? Complete Guide 4 min read Git Bash 9 min read Git Installation and SetupHow to Install GIT on Linux 4 min read Git - Environment Setup 2 min read How To Install Git on Ubuntu 20.04 3 min read How to Install Git in VS Code? 2 min read How to Install Git on Cygwin? 2 min read How to Install and Use GIT in Android Studio? 4 min read How to Setup Git Using Git Config? 3 min read Git- Setting up a Repository 3 min read How to install Git on Redhat Linux 9? 4 min read How to Install Git on Termux? 2 min read How to Install Git in FreeNAS? 4 min read How to Install Git on Raspberry Pi? 2 min read How to Install GIT on VMWare? 2 min read How to Install Git in Cpanel Server? 3 min read How To Install Git on AWS? 2 min read How to Setup Git Server on Ubuntu? 6 min read How to Install Git on Windows Subsystem for Linux? 2 min read All Git CommandsBasic Git Commands with Examples 4 min read 50+ Essential Git Commands for Beginners and Developers 7 min read Top 12 Git Commands for Every Developer 9 min read Essential Git Commands 3 min read Useful Git Commands and Basic Concepts 5 min read All Git Commands You Should Know 8 min read Simple and Concise Git Commands That Every Software Developer Should know 4 min read Most Used Git CommandsGit Init 3 min read Git Pull 4 min read Git Push 4 min read Git Clone 5 min read Git Rebase 8 min read How To Fetch Remote Branches in Git ? 3 min read Git Status 2 min read Git Add 2 min read Git Commit 2 min read Git Reset 3 min read Git BranchBranching Strategies in Git 8 min read Introduction to Git Branch 4 min read How To Create Branch In Git? 2 min read How to Create a Branch In Git from Another Branch? 3 min read How to Create a New Branch in Git and Push the Code? 8 min read How To Publish A New Branch In Git? 4 min read How to Create Git Branch With Current Changes? 1 min read Create a Git Branch From Another Branch 4 min read How to Create a New Branch in Git? 4 min read How to Create Branch From a Previous Commit Using Git? 2 min read How To Visualizing Branch Topology in Git? 3 min read How to Check Branch in Git? 2 min read How to Clone a Branch in Git? 3 min read How to Fetch All Git Branches? 2 min read Git MergeGit - Merge 4 min read Git Checkout And Merge 5 min read How to Merge Two Branches in Git? 4 min read How to Merge a Git Branch into Master? 3 min read How to Replace Master Branch with Another Branch in GIT? 2 min read Git Merge and Merge Conflict 3 min read Git Tools and IntegrationWorking on Git for GUI 4 min read How Git Version Control Works? 11 min read How To Write CI/CD Pipeline Using GitLab? 8 min read Git and DevOps: Integrating Version Control with CI/CD Pipelines 11 min read How To Create A Basic CI Workflow Using GitHub Actions? 5 min read How To Set Up Continuous Integration With Git and Jenkins? 4 min read How to Set Up a CI Pipeline for Ktor Using GitHub Actions? 6 min read Introduction to GitHub Actions 4 min read Basic CI Workflow For Android using GitHub Actions 2 min read Integrating Jenkins With Popular GitHub 8 min read Managing Git Repositories with GitLab 3 min read Git Remote RepositoriesUnderstanding Git Repository 4 min read Git- Setting up a Repository 3 min read Creating Repository in GitHub 3 min read Working With Git Repositories 7 min read Collaborating with GitGit - Fork 4 min read Difference Between fork and clone in GitHub 3 min read How to Fork a GitHub Repository? 3 min read Sync Your Fork With Master in GitHub 3 min read How to Update or Sync a Forked Repository on GitHub? 2 min read Advanced Git CommandsGit Rebase 8 min read Git - Difference Between Merging and Rebasing 3 min read What is Git Interactive Rebasing? 4 min read How to Undo a Git Rebase? 3 min read How To Rebase a Local Branch Onto a Remote Master in Git? 3 min read How to Fix - Git Refusing to Merge Unrelated Histories on Rebase? 3 min read Using Refs And Reflogs In Git 3 min read Recovering Lost Commits in Git 2 min read How to Restore a Deleted Branch or Commit with Git? 3 min read How to Change a Git Commit Message After a Push? 3 min read Git - Cherry Pick 6 min read How to cherry-pick Multiple Commits in Git? 4 min read How to Use the "cherry-pick" Command in Git? 3 min read Like