我有一个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 read-tree -mu HEAD
刚想出来,我会回答它,以防其他人有同样的问题。
在做出改变之后我需要做
git checkout themes/theme15
然后出现文件夹。事后看来可能很明显......(也许不是)。