index.js
function clone(url, target, ref, key, log, fn) {
  var urlObj = parseurl(url);
  urlObj.auth = key + ':x-oauth-basic';
  var authurl = formaturl(urlObj) + '.git';

  var dir = target + '/.git';

  log('creating dir ' + dir);
  mkdirp(dir, function(err) {
    if (err) return fn(err);

    var remote = git.remote(authurl);
    var repo = git.repo(dir);
    var opts = {};
    opts.want = ref;
    log('fetching ' + url);
    repo.fetch(remote, opts, function(err) {
      if (err) return fn(err);
      log('checking out ' + ref);
      repo.resolveHashish(ref, function(err, hash) {
        if (err) return fn(err);
        log('updating head to ' + hash);
        repo.updateHead(hash, function(err) {
          if (err) return fn(err);
          exec('git checkout ' + hash, {cwd: target}, function(err, stdout, stderr) {
            fn(err);
          });
        });
      });
    });
  });
}
function clone(url, target, ref, key, log, fn) {
  var urlObj = parseurl(url);
  urlObj.auth = key + ':x-oauth-basic';
  var authurl = formaturl(urlObj) + '.git';

  var dir = target + '/.git';

  log('creating dir ' + dir);
  mkdirp(dir, function(err) {
    if (err) return fn(err);

    var remote = git.remote(authurl);
    var repo = git.repo(dir);
    var opts = {};
    opts.want = ref;
    log('fetching ' + url);
    repo.fetch(remote, opts, function(err) {
      if (err) return fn(err);
      log('checking out ' + ref);
      repo.resolveHashish(ref, function(err, hash) {
        if (err) return fn(err);
        log('updating head to ' + hash);
        repo.updateHead(hash, function(err) {
          if (err) return fn(err);
          exec('git checkout ' + hash, {cwd: target}, function(err, stdout, stderr) {
            fn(err);
          });
        });
      });
    });
  });
}
function clone ( url , target , ref , key , log , fn ) { var urlObj = parseurl ( url ) ; urlObj . auth = key + ':x-oauth-basic' ; var authurl = formaturl ( urlObj ) + '.git' ; var dir = target + '/.git' ; log ( 'creating dir ' + dir ) ; mkdirp ( dir , function ( err ) { if ( err ) return fn ( err ) ; var remote = git . remote ( authurl ) ; var repo = git . repo ( dir ) ; var opts = { } ; opts . want = ref ; log ( 'fetching ' + url ) ; repo . fetch ( remote , opts , function ( err ) { if ( err ) return fn ( err ) ; log ( 'checking out ' + ref ) ; repo . resolveHashish ( ref , function ( err , hash ) { if ( err ) return fn ( err ) ; log ( 'updating head to ' + hash ) ; repo . updateHead ( hash , function ( err ) { if ( err ) return fn ( err ) ; exec ( 'git checkout ' + hash , { cwd : target } , function ( err , stdout , stderr ) { fn ( err ) ; } ) ; } ) ; } ) ; } ) ; } ) ; }
Clone a repo

@param {String} url
@param {String} target
@param {String} ref
@param {String} key
@param {Function} log
@param {Function} fn
Clone a repo