src/commands.js
function checkout(options) {
    var branchOrTag = options.branch || options.tag;

    assert.ok(branchOrTag, 'branch or tag is mandatory');

    if ((options.create || options.oldCreate) && options.orphan) {
      throw new Error('create and orphan cannot be specified both together');
    }

    if (options.create && options.oldCreate) {
      throw new Error('create and oldCreate cannot be specified both together');
    }

    var args = [
      'checkout',
      options.create ? '-B' : options.oldCreate ? '-b' : null,
      options.orphan ? '--orphan' : null,
      branchOrTag,
      options.force ? '-f' : null
    ];

    return git(args)
        .then(silent);
  }
function checkout(options) {
    var branchOrTag = options.branch || options.tag;

    assert.ok(branchOrTag, 'branch or tag is mandatory');

    if ((options.create || options.oldCreate) && options.orphan) {
      throw new Error('create and orphan cannot be specified both together');
    }

    if (options.create && options.oldCreate) {
      throw new Error('create and oldCreate cannot be specified both together');
    }

    var args = [
      'checkout',
      options.create ? '-B' : options.oldCreate ? '-b' : null,
      options.orphan ? '--orphan' : null,
      branchOrTag,
      options.force ? '-f' : null
    ];

    return git(args)
        .then(silent);
  }
function checkout ( options ) { var branchOrTag = options . branch || options . tag ; assert . ok ( branchOrTag , 'branch or tag is mandatory' ) ; if ( ( options . create || options . oldCreate ) && options . orphan ) { throw new Error ( 'create and orphan cannot be specified both together' ) ; } if ( options . create && options . oldCreate ) { throw new Error ( 'create and oldCreate cannot be specified both together' ) ; } var args = [ 'checkout' , options . create ? '-B' : options . oldCreate ? '-b' : null , options . orphan ? '--orphan' : null , branchOrTag , options . force ? '-f' : null ] ; return git ( args ) . then ( silent ) ; }
Checkout a local branch

Executes `git checkout -B issues/12`

If you specify create, it will try to create the branch,
or will checkout it if it already exists

If both a branch and a tag are specified, the branch takes precedence

Cannot use create and orphan both together

@example
var git = require('gitftw');

git.checkout({
branch: 'master'
});

@memberof git
@type {command}

@param {Object} options The options object. All its properties are {@link Resolvable}
@param {Resolvable|String} options.branch The branch to checkout
@param {Resolvable|String} [options.tag] The tag to checkout
@param {Resolvable|Boolean} [options.create] Try to create the branch (-B flag)
@param {Resolvable|Boolean} [options.oldCreate] Try to create the branch (-b flag). Do
not use along with 'create'.
@param {Resolvable|Boolean} [options.orphan] Create an orphan branch (--orphan flag)
@param {Resolvable|Boolean} [options.force] When switching branches, proceed even if
the index or the working tree differs from HEAD. This is used to throw
away local changes. (-f flag)
@param {callback} [cb] The execution callback result
@returns {Promise} Promise Resolves with undefined
Checkout a local branch