0

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.

shrini
  • 35
  • 1
  • 5
  • 1
    You want `git sparse-checkout add`, not `git sparse-checkout set`. The sparse checkout code is evolving now so you may need to update your Git version to get some of the newest features; if you don't have `git sparse-checkout add`, it's in a newer Git release. – torek Mar 17 '22 at 09:55

1 Answers1

0

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.

shrini
  • 35
  • 1
  • 5