Clone a git repo to a folder on disk (or if the folder already exists, just pull)
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 () {
},
});
The path where the remote repo should be pulled (will be created if necessary)
'./'
The git remote to pull from (defaults to "origin", but you can specify a named remote or URL)
'origin'
The remote branch to pull (defaults to "master")
'master'
An unexpected error occurred.
Specified directory is not a git repository (and neither are any of its parents)
Insufficient permissions (i.e. you might need to use `chown`/`chmod`)
Specified directory does not exist.
Cannot pull because uncommitted/unstashed local changes exist locally and would be overwritten by merge.
Cannot pull because this local repo has unmerged conflicts.
The command failed-- the local repo may now be in an invalid/unmerged state. Please verify that this is not the case.
OK.