如何在编辑稀疏结账后让git下载一个新文件夹?

问题描述 投票:2回答:2

我有一个git repo,我只想下载某些子文件夹。我的配置如下所示:

#.git/config

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    sparsecheckout = true
[remote "dreamhost"]
  url = <repo url>
  fetch = +refs/heads/*:refs/remotes/dreamhost/*
[push]
  default = tracking  

.git/info/sparse-checkout我有这个:

themes/theme1
themes/theme8

这是我想要的themes子文件夹中的文件夹。 (我不需要其他人,其中很多)。

如果我做一个git / pull我可以看到git获取很多东西,包括我不想要的themes子文件夹,这很好。我知道稀疏结账仍然会拉下物体。

我现在想要一份themes/theme15,进行一些修改。所以,我编辑了.git/info/sparse-checkout

themes/theme1
themes/theme8
themes/theme15

然后做了一个git pull dreamhost master,认为git会在themes下添加theme15文件夹。但是,没有任何反应 - 它只是说

From <repo url>
 * branch            master     -> FETCH_HEAD
Already up-to-date.

和文件夹不在那里。谁能告诉我我做错了什么?编辑.git/info/sparse-checkout后还有一个额外的步骤吗?

谢谢,马克斯

编辑:这是在git version 2.8.1顺便说一句

git sparse-checkout
2个回答
5
投票

将我的文件夹添加到稀疏结帐文件后,我需要执行的步骤是:

git read-tree -mu HEAD

0
投票

刚想出来,我会回答它,以防其他人有同样的问题。

在做出改变之后我需要做

git checkout themes/theme15

然后出现文件夹。事后看来可能很明显......(也许不是)。

© www.soinside.com 2019 - 2024. All rights reserved.