0

Situation

I managed to create a local git repository in my laptop by pulling a single subdirectory of the master branch in a remote repository. I have followed the instructions given in this post on https://stackoverflow.com/a/13738951/5459638. I use git version 2.22.0.

The path of the subdirectory, with respect to https://gitlab.com/<user>/<project>/tree/master as given in the project web page, is contained in the file .git/info/sparse-checkout, say

subdir1/subdir11/

The command

git pull mylaptop master

does create a local copy of the intended directories. This is confirmed with a tree -d. mylaptop was a name of choice for the local repository. This worked fine.

Issue

I then wanted to fetch a sibling directory and its child from the same remote too, say

subdir1/subdir12/

I added this path as a new line in the sparse-checkout file and run the git pull command above. However, the outcome is

From https://gitlab.com/<user>/<project>
* branch            master     -> FETCH_HEAD
Already up to date.

and I see no change in the local tree.

Research

Out of several suggestions I came across in Stackoverflow, I gave it a try to git update-index --skip-worktree, but to no avail. I did this out of intution and would avoid blind trials though. It is not a question of trailing slashes in the paths either.

Question

Apparently I am missing something that makes Git realize that the list has been extended. What could this be?

Community
  • 1
  • 1
XavierStuvw
  • 1,294
  • 2
  • 15
  • 30

2 Answers2

2

After adding the new path to .git/info/sparse-checkout do

git checkout master

Thus, you do this instead of the initial git pull command.

romor
  • 1,181
  • 15
  • 22
0

You will need to merge and update the files in the work tree.

Simply run:

git read-tree -mu HEAD

More information: git-read-tree

hasi90
  • 84
  • 8