How to sync a single folder from a remote git repository - ami-iit/ami-commons GitHub Wiki

Sometimes you wish to download from or synchronize with a remote repo a single folder containing a dataset, images, or just a couple of files, without pulling the full repository content on your local machine. this is a critical requirement if you are dealing with very large repositories (>10 Go).

How to sync a single folder on git

  1. first create and init the local repo (creates the .git but doesn't fully populate it):
cd <repoPath>
git init
git remote add origin <repoUrl>
  1. activate the sparse checkout option:
git config core.sparseCheckout true
  1. write in file sparse-checkout the list of folders you wish to synchronize
echo "<folder_name_1>" >> .git/info/sparse-checkout
echo "<folder_name_2>" >> .git/info/sparse-checkout
  1. Pull the repo (downloads the full repo history info, but not all the files contents, only the ones in the selected folder)
git pull origin master
⚠️ **GitHub.com Fallback** ⚠️