Method: Git::Lib#checkout

Defined in:
lib/git/lib.rb

#checkout(branch = nil, opts = {})

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Runs checkout command to checkout or create branch

accepts options: :new_branch :force :start_point

Parameters:

  • branch (String) (defaults to: nil)
  • opts (Hash) (defaults to: {})


1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
# File 'lib/git/lib.rb', line 1302

def checkout(branch = nil, opts = {})
  if branch.is_a?(Hash) && opts.empty?
    opts = branch
    branch = nil
  end
  ArgsBuilder.validate!(opts, CHECKOUT_OPTION_MAP)

  flags = build_args(opts, CHECKOUT_OPTION_MAP)
  positional_args = build_checkout_positional_args(branch, opts)

  command('checkout', *flags, *positional_args)
end