I have a git repo where I only want to download certain subfolders. My config looks like this:
#.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
In .git/info/sparse-checkout
i had this:
themes/theme1
themes/theme8
which are the folders within the themes
subfolder that I want to get. (I don't need the others, which are many).
If i do a git/pull I can see git fetching lots of stuff, including the themes
subfolders which I don't want, which is fine. I know that sparse-checkout still pulls down the objects.
I now want to have a copy of themes/theme15
, to make some changes. So, I edited .git/info/sparse-checkout
thus:
themes/theme1
themes/theme8
themes/theme15
and then did a git pull dreamhost master
, thinking that git would add the theme15 folder under themes
. But, nothing happens - it just says
From <repo url>
* branch master -> FETCH_HEAD
Already up-to-date.
and the folder's not there. Can anyone tell me what I'm doing wrong? Is there an extra step after editing .git/info/sparse-checkout
?
thanks, Max
EDIT: this is in git version 2.8.1
btw
"Sparse checkout" allows populating the working directory sparsely. It uses the skip-worktree bit (see git-update-index[1]) to tell Git whether a file in the working directory is worth looking at. If the skip-worktree bit is set, and the file is not present in the working tree, then its absence is ignored.
sparseCheckout config setting. Then, run git sparse-checkout set to modify the patterns in the sparse-checkout file. To repopulate the working directory with all files, use the git sparse-checkout disable command.
If you want to clone the git repository into the current directory, you can do like: $ git clone <repository> . Here, the dot (.) represents the current directory.
The step I needed to perform to make my folder appear after adding it to my sparse-checkout file was:
git read-tree -mu HEAD
Just figured this out, I'll answer it in case anyone else has the same problem.
After making the change I needed to do
git checkout themes/theme15
then the folder appears. Perhaps obvious in hindsight....(perhaps not).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With