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?

2
  • Try git checkout. Commented Aug 5, 2019 at 9:59
  • @ElpieKay When? That is, after and before what? Commented Aug 5, 2019 at 14:19

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

I was having trouble with this feature, and have since found the answer. It turns out that git sparse-checkout set is used to set one or more folders that you want to be able to pull down, it is used for setting a specific list of folders - if you perform it again with a different folder it will wipe out the previous list.

If you want do add an additional folder you use git sparse-checkout add

You don't seem to have to redo the pull the moment you update it it pulls down the files.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.