org.eclipse.jgit.api

## Class CreateBranchCommand

- java.lang.Object
- - org.eclipse.jgit.api.GitCommand<Ref>
  - - org.eclipse.jgit.api.CreateBranchCommand

All Implemented Interfaces:
  Callable<Ref>

    public class CreateBranchCommand
    extends GitCommand<Ref>

Used to create a local branch.

See Also:
  Git documentation about Branch

### Nested Class Summary

Nested Classes
`static class` `CreateBranchCommand.SetupUpstreamMode` The modes available for setting up the upstream configuration (corresponding to the --set-upstream, --track, --no-track options

### Field Summary

### Fields inherited from class org.eclipse.jgit.api.GitCommand

`repo`

### Constructor Summary

Constructors
`protected` `CreateBranchCommand(Repository repo)`

### Method Summary

Methods
`Ref` `call()` Executes the command
`CreateBranchCommand` `setForce(boolean force)`
`CreateBranchCommand` `setName(String name)`
`CreateBranchCommand` `setStartPoint(RevCommit startPoint)`
`CreateBranchCommand` `setStartPoint(String startPoint)`
`CreateBranchCommand` `setUpstreamMode(CreateBranchCommand.SetupUpstreamMode mode)`

### Methods inherited from class org.eclipse.jgit.api.GitCommand

`checkCallable, getRepository, setCallable`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### CreateBranchCommand

    protected CreateBranchCommand(Repository repo)

Parameters:
  `repo` -

### Method Detail

#### call

    public Ref call()
             throws GitAPIException,
                    RefAlreadyExistsException,
                    RefNotFoundException,
                    InvalidRefNameException

Description copied from class: `GitCommand`
Executes the command

Specified by:
  `call` in interface `Callable<Ref>`
Specified by:
  `call` in class `GitCommand<Ref>`
Returns:
  the newly created branch
Throws:
  `RefAlreadyExistsException` - when trying to create (without force) a branch with a name that already exists
  `RefNotFoundException` - if the start point can not be found
  `InvalidRefNameException` - if the provided name is `null` or otherwise invalid
  `GitAPIException` - or subclass thereof when an error occurs

#### setName

    public CreateBranchCommand setName(String name)

Parameters:
  `name` - the name of the new branch
Returns:
  this instance

#### setForce

    public CreateBranchCommand setForce(boolean force)

Parameters:
  `force` - if `true` and the branch with the given name already exists, the start-point of an existing branch will be set to a new start-point; if false, the existing branch will not be changed
Returns:
  this instance

#### setStartPoint

    public CreateBranchCommand setStartPoint(String startPoint)

Parameters:
  `startPoint` - corresponds to the start-point option; if `null`, the current HEAD will be used
Returns:
  this instance

#### setStartPoint

    public CreateBranchCommand setStartPoint(RevCommit startPoint)

Parameters:
  `startPoint` - corresponds to the start-point option; if `null`, the current HEAD will be used
Returns:
  this instance

#### setUpstreamMode

    public CreateBranchCommand setUpstreamMode(CreateBranchCommand.SetupUpstreamMode mode)

Parameters:
  `mode` - corresponds to the --track/--no-track/--set-upstream options; may be `null`
Returns:
  this instance