Analyze. Act. Achieve.
Kurinchilion KURINCHILION Analyze. Act. Achieve.

News

Git sparse checkout or partial checkout

 

There are scenarios when you are contributing to a subset of a very large project. Instead of downloading the entire project, you may want to bring down a copy of ONLY the needed folders or files (to save download time, space ...)

Git allows partial cloning which allows Git to function without having a complete copy of the repository. Follow the below steps to try out Git's sparse-checkout feature.

$ git --version

git version 2.24.1.windows.2

$ mkdir myproject

$ cd myproject

$ git init

$ git remote add -f origin <<[REPO URL]>>

$ git config core.sparseCheckout true

$ echo "folder1/" >> .git/info/sparse-checkout

$ echo "folder1/" >> .git/info/sparse-checkout

$ git pull --depth=1 origin master

Now, check the files/folders and you will notice that only the files/folders that you have specified in the sparse-checkout process are the ones that is getting downloaded.