Class: Git::Lib::HeadState

Inherits:
Struct
  • Object
show all
Defined in:
lib/git/lib.rb

Overview

The state and name of branch pointed to by HEAD

HEAD can be in the following states:

:active: HEAD points to a branch reference which in turn points to a commit representing the tip of that branch. This is the typical state when working on a branch.

:unborn: HEAD points to a branch reference that does not yet exist because no commits have been made on that branch. This state occurs in two scenarios:

  • When a repository is newly initialized, and no commits have been made on the initial branch.
  • When a new branch is created using git checkout --orphan <branch>, starting a new branch with no history.

:detached: HEAD points directly to a specific commit (identified by its SHA) rather than a branch reference. This state occurs when you check out a commit, a tag, or any state that is not directly associated with a branch. The branch name in this case is HEAD.

Instance Attribute Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



737
738
739
# File 'lib/git/lib.rb', line 737

def name
  @name
end

#stateObject

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



737
738
739
# File 'lib/git/lib.rb', line 737

def state
  @state
end