Method: MultiGit::Repository#branch

Defined in:
lib/multi_git/repository.rb

#branch(name) ⇒ Ref

Opens a branch

Examples:

# setup:
dir = `mktemp -d`
# example:
repository = MultiGit.open(dir, init: true)
# getting a local branch
repository.branch('master') #=> be_a MultiGit::Ref
# getting a remote branch
repository.branch('origin/master') #=> be_a MultiGit::Ref
# teardown:
`rm -rf #{dir}`

Parameters:

  • name (String)

    branch name

Returns:



162
163
164
165
166
167
168
# File 'lib/multi_git/repository.rb', line 162

def branch(name)
  if name.include? '/'
    ref('refs/remotes/'+name)
  else
    ref('refs/heads/'+name)
  end
end