Git.pullOrClone()

Clone a git repo to a folder on disk (or if the folder already exists, just pull)

Usage

Hover over inputs/exits for more info.

var Git = require('machinepack-git');


// Clone a git repo to a folder on disk (or if the folder already exists, just pull)

Git.pullOrClone({

destination: './',

remote: 'origin',

branch: 'master',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// Specified directory is not a git repository (and neither are any of its parents)

notRepo: function () {

 

},

// Insufficient permissions (i.e. you might need to use `chown`/`chmod`)

forbidden: function () {

 

},

// Specified directory does not exist.

noSuchDir: function () {

 

},

// Cannot pull because uncommitted/unstashed local changes exist locally and would be overwritten by merge.

uncommittedChanges: function () {

 

},

// Cannot pull because this local repo has unmerged conflicts.

unresolvedConflicts: function () {

 

},

// The command failed-- the local repo may now be in an invalid/unmerged state. Please verify that this is not the case.

failed: function () {

 

},

// OK.

success: function () {

 

},

});

Inputs

destination required

The path where the remote repo should be pulled (will be created if necessary)

'./'
remote

The git remote to pull from (defaults to "origin", but you can specify a named remote or URL)

'origin'
branch

The remote branch to pull (defaults to "master")

'master'

Exits

error

An unexpected error occurred.

notRepo

Specified directory is not a git repository (and neither are any of its parents)

forbidden

Insufficient permissions (i.e. you might need to use `chown`/`chmod`)

noSuchDir

Specified directory does not exist.

uncommittedChanges

Cannot pull because uncommitted/unstashed local changes exist locally and would be overwritten by merge.

unresolvedConflicts

Cannot pull because this local repo has unmerged conflicts.

failed

The command failed-- the local repo may now be in an invalid/unmerged state. Please verify that this is not the case.

success

OK.