Articles

Checkout subdirectory in a git repository

In howto on Jul 13, 2016 by theoryl Tagged: , , ,

To checkout a subdirectory in a Git repository using sparse-checkout, follow these instructions

git remote add -f origin https://github.com/whoever/whatever.git
git config core.sparsecheckout true
echo /path/to/subdirectory >> .git/info/sparse-checkout
git checkout master

Alternatively

git clone https://github.com/whoever/whatever.git
cd whatever
git config core.sparsecheckout true
echo /path/to/subdirectory >> .git/info/sparse-checkout
git read-tree -mu HEAD

Also see this StackOverflow answer.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: