code: function prepareRepo(remoteUrl, origin, dir) {
    let promise
  
    if (remoteUrl) {
      // if a remoteUrl was provided, use it
      promise = wrapPromise.Promise.resolve(remoteUrl)
    } else {
      // else try to extract it from the .git folder of
      // the current directory.
      promise = getRemoteUrl(git(process.cwd()), origin)
    }
  
    return promise.catch(function (e) { console.error(e) }).then(function (rUrl) {
      remoteUrl = rUrl
  
      return wrapPromise(function (resolve, reject) {
        function initRepo(repo) {
          repo.branch(function (err, head) {
            if (err) {
              reject(err)
              return
            }
  
            resolve(new Git(repo, head.name).status())
          })
        }
  
        function clearAndInitRepo() {
          rimraf(dir, function (rmErr) {
            if (rmErr) {
              reject(rmErr)
              return
            }
  
            git.clone(rUrl, dir, function (cloneErr, repo) {
              if (cloneErr) {
                reject(cloneErr)
                return
              }
  
              initRepo(repo)
            })
          })
        }
  
        // assume that if there is a .git folder get its remoteUrl
        // and check if it mathces the one we want to use.
        getRemoteUrl(git(dir), origin).then(function (cwdRemoteUrl) {
          if (remoteUrl === cwdRemoteUrl) {
            initRepo(git(dir))
            return
          }
  
          clearAndInitRepo()
        }, function () {
  
          clearAndInitRepo()
        })
      })
    }).catch(function (err) {
      console.error(err)
    })
  }
docs: /*
  Clone repo
  Returns repo object