0

I'm trying to clone a Git repository that resides on my local drive into a new folder. So far, I've tried several modules, from which creationix/js-git seemed to be the most promising one.

The code to fetch I use is:

  var source = '...',
      target = '...';

  var remoteRepository = git.remote('file://' + source),
      localRepository = git.repo(target);

  var options = {
    onProgress: function (progress) {
      console.log(progress);
    }
  };

  localRepository.fetch(remoteRepository, options, function (err) {
    if (err) { throw err; }
    console.log('Done');
  });

Unfortunately, this does not work, as js-git complains about an unknown URL format, which relates to the file:// protocol being used. The same error appears when I remove the file:// portion.

I also tried to change git.remote to git.repo (as it's not an actual remote), but then I get:

TypeError: Object #<Object> has no method 'discover'

So, apparently js-git does not support fetching from local repositories (or I was not able to find out how to do it).

Does anyone…

  • …either know how to solve this using js-git,
  • or can suggest a viable alternative?

Any help is appreciated :-)

Golo Roden
  • 140,679
  • 96
  • 298
  • 425
  • 2
    Why can't you just use child_process.exec and a command line option ? – c0d3junk13 Mar 13 '14 at 11:08
  • Because it shall run on OS X, Linux and Windows, and I don't have the target machines under my control, and I'm not too sure whether an end user will be able to correctly (!) setup Git, especially on Windows. – Golo Roden Mar 13 '14 at 11:10

0 Answers0