0

I have a remote named git@github.com:MyOrg/my-repo.git

There are several folders within its root directory.

I only want to fetch ONE of them, named datadog.

I am running the following commands

$ g clone --no-checkout --depth=1 git@github.com:MyOrg/my-repo.git
Cloning into 'my-repo'
...
...
...

$ cd my-repo

$ git sparse-checkout init

$ git sparse-checkout set datadog

$ ls -al
total 0
drwxr-xr-x   3 pantelis  wheel    96B Oct  8 12:39 .
drwxrwxrwt  37 root      wheel   1.2K Oct  8 12:39 ..
drwxr-xr-x  13 pantelis  wheel   416B Oct  8 12:41 .git

$ g sparse-checkout list
datadog

$ g checkout master
Already on 'master'
Your branch is up to date with 'origin/master'.

$ ls -al
total 0
drwxr-xr-x   5 pantelis  wheel   160B Oct  8 12:41 .
drwxrwxrwt  37 root      wheel   1.2K Oct  8 12:39 ..
drwxr-xr-x  14 pantelis  wheel   448B Oct  8 12:41 .git
drwxr-xr-x   9 pantelis  wheel   288B Oct  8 12:41 datadog
drwxr-xr-x   4 pantelis  wheel   128B Oct  8 12:41 terragrunt

Where did that terragrunt directory come from? I know it is in my repo's root by why was it added in my sparse-checkout?

update: If I use the --cone option when initialising sparse-checkout it will indeed add only datadog folder but also ALL other root files (README.md, LICENSE.md etc) which isn't the desired behaviour either.

pkaramol
  • 16,451
  • 43
  • 149
  • 324
  • Can you create a sample repository so that others can test ? – Philippe Oct 08 '21 at 13:54
  • I tried to reproduce this on my linux box using [this](https://github.com/pkaramol/test-repo) public repo I just created and it is not reproducible. On my mac I have `git` 2.33.0 and on my `linux` I have 2.25.1; I will try to install the same `git` version on my mac – pkaramol Oct 08 '21 at 18:29
  • Note that sparse checkout is evolving (it's been undergoing some rather massive changes recently). The version difference in this case would explain everything. – torek Oct 08 '21 at 19:26
  • I tested getting expected result (only datadog) on `git version 2.30.1 (Apple Git-130)`. Working as well on Linux `git version 2.25.1` – Philippe Oct 08 '21 at 20:37

0 Answers0