OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 9:11 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Clone/download a subdirectory of a git repository
PostPosted: Fri May 15, 2020 4:09 pm 
Offline
Member
Member
User avatar

Joined: Mon Jun 05, 2006 11:00 pm
Posts: 2293
Location: USA (and Australia)
I'm trying to download a copy of just libc++/libc++abi from the LLVM git repo.

I was following the answer here: https://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository

Code:
git init
git remote add -f origin https://github.com/llvm/llvm-project.git
git config core.sparseCheckout true
git config pull.ff only
echo "libcxx/" >> .git/info/sparse-checkout
echo "libcxxabi/" >> .git/info/sparse-checkout
git pull --depth=1 origin master


However, at 'git remote add', it tries to download nearly 1GB of data (the entire repo.)

How can I just clone/download the two subdirectories I care about?

_________________
My OS is Perception.


Top
 Profile  
 
 Post subject: Re: Clone/download a subdirectory of a git repository
PostPosted: Fri May 15, 2020 11:45 pm 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
You need to use absolute pathnames in the sparse-checkout file.

Also, have a look at this thread: https://stackoverflow.com/questions/411 ... repository

versions of git newer that 2.25.0 have a "sparse-checkout" command that makes it easier to work with sparse checkouts.

Edit: OK - having checked out that latter thread, here is the sequence of events you need:
Code:
git clone --no-checkout --depth 1 git://github.com/llvm/llvm-project.git
cd llvm-project
git config core.sparsecheckout true
echo "libcxx/*" > .git/info/sparse-checkout
echo "libcxxabi/*" >> .git/info/sparse-checkout
git checkout
This is tested, and working, on Linux. I believe that on Windows you need to omit the quotes in the echo commands, but I haven't tested this.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 44 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group