Home > Software design >  git sparse-checkout existing repo serially
git sparse-checkout existing repo serially

Time:03-22

Here is what I am doing

First sparse-check-out

 git clone --depth 1 --filter=blob:none --sparse https:<repo_path>
 cd ./<local_repo_path>
 git sparse-checkout init --cone
 git sparse-checkout set <first_desired_folder>

I need to run something from the <first_desired_folder> above to decide what to sparse-checkout further

$VAR = ./<local_repo_path>/<first_desired_folder>/someprogram.py 

Second sparse-checkout is based on the $VAR above

git sparse-checkout set models/"$VAR-model"

I want to keep the <first_desired_folder> intact while doing the second sparse check-out above. The <local_repo_path> is only with models/$VAR-model and <first_desired_folder> disappears. How to achieve this serial sparse-checkouts keeping preserving both the folders. I tried this configuring existing git repo for sparse checkout But it is not working.

One brute-force way is to sparse-checkout <first_desired_folder> along with models/$VAR-model in the second step but I was wondering if there is more elegant solution to this.

CodePudding user response:

The answer is THANKS to @torek.

In the second sparse-checkout instead of set, we should be using add

git sparse-checkout add models/"$VAR-model"

This works very well.

  • Related