Hachecode
Hachecode

Reputation: 31

How can I clone a git's repository subdirectory content?

I have been able to clone only a subdirectory of a git repository using sparse:

git init <repo>
cd <repo>
git remote add origin <url>
git config core.sparsecheckout true
echo "DEPLOY/*" >> .git/info/sparse-checkout
git pull --depth=1 origin master

Now, I would like to clone only DEPLOY directory content, not the directory itself. Does exist any way to do that?

Upvotes: 2

Views: 80

Answers (2)

SL5net
SL5net

Reputation: 2556

i also was not able to get sub-directory content.

the best for something similar problem was to jump easier into the subdir by using a symlink later

mkdir gitFullRepo; cd gitFullRepo;
git init; 
git remote add -f origin [email protected]:repo/repo.git;
git config core.sparsecheckout true; echo "subDir/" >> .git/info/sparse-checkout; 
git pull origin master;
cd ..; 

ln -s ./gitFullRepo/subDir/ ./hereIWantWork;  

Upvotes: 0

VonC
VonC

Reputation: 1323115

No, that would still be a sparsed checkout.

You would simply have to follow with a copy or a move of the DEPLOY content to where you need it.

Upvotes: 1

Related Questions