0

I just started using simple-git and I have a question: is it possible to clone all the files from one folder on a repository instead of the whole thing? My code is this:

const simplegit = require('simple-git')
const git = simplegit()

const repo = 'https://github.com/PrinceKomali/bot-index/';
const path = './test';
const options = [];

const handler = () => {
    console.log('DONE')
};

git.clone(repo, path, options, handler());

Running this clones the entire repository but I only need the contents of the pages folder. How can I do this

Komali
  • 196
  • 9
  • I don't know what simple-git is, but you can find an answer with Git [here](https://stackoverflow.com/questions/600079/git-how-do-i-clone-a-subdirectory-only-of-a-git-repository) – prosoitos Oct 11 '20 at 16:45
  • Maybe this SO post may help you in sometthing: [How to pull specific directory with git](https://stackoverflow.com/questions/2425059/how-to-pull-specific-directory-with-git) – Jorge Luiz Oct 11 '20 at 17:19
  • Thank you both, however I have seen these; I am just not sure how to implement them (https://www.npmjs.com/package/simple-git) I've found a solution that works for now but its pretty crude, involving `fs` and reading/copying/deleting folders – Komali Oct 11 '20 at 18:04
  • My scenario is to clone a branch to another Repo in node.js. do you know how we can use options in simple-git package. – karan arora Feb 27 '23 at 11:46

0 Answers0