Class: Git::Commands::Init Private

Inherits:
Base
  • Object
show all
Defined in:
lib/git/commands/init.rb

Overview

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

Note:

arguments block audited against https://git-scm.com/docs/git-init/2.53.0

Implements the git init command

Create an empty Git repository or reinitialize an existing one.

Examples:

Typical usage

init = Git::Commands::Init.new(execution_context)
init.call
init.call('my-repo')
init.call('my-repo.git', bare: true)
init.call('my-repo', initial_branch: 'main')
init.call('my-repo', template: '/path/to/templates')

See Also:

Instance Method Summary collapse

Methods inherited from Base

allow_exit_status, arguments, #initialize, requires_git_version, skip_version_validation

Constructor Details

This class inherits a constructor from Git::Commands::Base

Instance Method Details

#call(directory = nil, **options) ⇒ Git::CommandLineResult

Execute the git init command

Parameters:

  • directory (String, nil) (defaults to: nil)

    path to the directory to initialize

    If nil or omitted, initializes the repository in the current directory (.).

    If :bare is false, initializes .git inside this directory. If :bare is true, creates the bare repository directly in this directory.

  • options (Hash)

    command options

Options Hash (**options):

  • :quiet (Boolean, nil) — default: nil

    suppress all output except errors and warnings

    Alias: :q

  • :bare (Boolean, nil) — default: nil

    create a bare repository

  • :template (String) — default: nil

    path to the directory from which templates will be used

  • :separate_git_dir (String) — default: nil

    path at which to create the repository; writes a gitfile at the working-tree root pointing to it

  • :object_format (String) — default: nil

    hash algorithm for the repository (sha1 or sha256)

  • :ref_format (String) — default: nil

    ref storage format for the repository (files or reftable)

  • :initial_branch (String) — default: nil

    name to use for the initial branch in the newly created repository

    Alias: :b

  • :shared (Boolean, String, nil) — default: nil

    configure the repository to be shared among multiple users

    Pass true to emit --shared (which defaults to group permissions). Pass a string (e.g. 'group', 'all', '0660') to emit --shared=<permissions>.

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/init.rb', line 43