10

I want to require only a sub portion of a git repository (instead of the full thing). The reason i want to do this is because the repository is huge.

In my case the repository is: https://github.com/pubnub/pubnub-api.git and I only want the /php directory.

I have the following package defined in composer:

 { "type": "package", "package": { "name": "pubnub", "version": "dev-master", "source" : { "url": "https://github.com/pubnub/pubnub-api.git", "type": "git", "reference":"master" } } }, 

Any tips?

3
  • 1
    Please remember that the best you can do is to retrieve a bare repository (nothing in the working directory), then checkout the files in php. You will still end up with all of the history using git clone (as I guess that Composer does behind the scenes). Commented Jan 25, 2013 at 19:52
  • I am looking for the same behaviour. Any luck? Commented Oct 10, 2013 at 7:47
  • 2
    I am interested in getting part of repository with composer. Commented Oct 10, 2013 at 8:20

2 Answers 2

10
+300

Given the answer to "Is there any way to clone a git repository's sub-directory only?" Is "No" , and sub directory checkout functionality would be required by composer to satisfy the desired functionality, then I would suggest the best composer could do was checkout the whole thing and then delete what you didnt want.

In short: Not Possible.

The longer answer: is that git can do a sparse checkout so in theory composer could someday support that feature. You can use the autoload field to only load the section of code you want (ie, not load the whole lib).

Sign up to request clarification or add additional context in comments.

Comments

1

It seems that the php directory has been moved on its own repository here https://github.com/pubnub/php. That may help for this project, but no idea how to achieve this from main repo and composer...

2 Comments

Oh, I need another repository which not divided.
@flavien, thanks for the notes, but it doesnt answer the general question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.