Package org.eclipse.jgit.api
Class CreateBranchCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<Ref>
-
- org.eclipse.jgit.api.CreateBranchCommand
-
- All Implemented Interfaces:
java.util.concurrent.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 Modifier and Type Class Description 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 Modifier Constructor Description protected
CreateBranchCommand(Repository repo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Ref
call()
Executes the commandCreateBranchCommand
setForce(boolean force)
CreateBranchCommand
setName(java.lang.String name)
CreateBranchCommand
setStartPoint(java.lang.String startPoint)
CreateBranchCommand
setStartPoint(RevCommit startPoint)
CreateBranchCommand
setUpstreamMode(CreateBranchCommand.SetupUpstreamMode mode)
-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
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 interfacejava.util.concurrent.Callable<Ref>
- Specified by:
call
in classGitCommand<Ref>
- Returns:
- the newly created branch
- Throws:
RefAlreadyExistsException
- when trying to create (without force) a branch with a name that already existsRefNotFoundException
- if the start point can not be foundInvalidRefNameException
- if the provided name isnull
or otherwise invalidGitAPIException
- or subclass thereof when an error occurs
-
setName
public CreateBranchCommand setName(java.lang.String name)
- Parameters:
name
- the name of the new branch- Returns:
- this instance
-
setForce
public CreateBranchCommand setForce(boolean force)
- Parameters:
force
- iftrue
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(java.lang.String startPoint)
- Parameters:
startPoint
- corresponds to the start-point option; ifnull
, the current HEAD will be used- Returns:
- this instance
-
setStartPoint
public CreateBranchCommand setStartPoint(RevCommit startPoint)
- Parameters:
startPoint
- corresponds to the start-point option; ifnull
, 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 benull
- Returns:
- this instance
-
-