简体   繁体   中英

Git sparse checkout: adding directories to existing list is not recognized

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?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM