- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<Ref>
-
- org.eclipse.jgit.api.CreateBranchCommand
-
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 classCreateBranchCommand.SetupUpstreamModeThe 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 protectedCreateBranchCommand(Repository repo)Constructor for CreateBranchCommand
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Refcall()static booleanisValidBranchName(String branchName)Check if the given branch name is validCreateBranchCommandsetForce(boolean force)Set whether to create the branch forcefullyCreateBranchCommandsetName(String name)Set the name of the new branchCreateBranchCommandsetStartPoint(String startPoint)Set the start pointCreateBranchCommandsetStartPoint(RevCommit startPoint)Set the start pointCreateBranchCommandsetUpstreamMode(CreateBranchCommand.SetupUpstreamMode mode)Set the upstream mode-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Constructor Detail
-
CreateBranchCommand
protected CreateBranchCommand(Repository repo)
Constructor for CreateBranchCommand- Parameters:
repo- theRepository
-
-
Method Detail
-
call
public Ref call() throws GitAPIException, RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException
Execute the command
- Specified by:
callin interfaceCallable<Ref>- Specified by:
callin classGitCommand<Ref>- Throws:
GitAPIExceptionRefAlreadyExistsExceptionRefNotFoundExceptionInvalidRefNameException
-
isValidBranchName
public static boolean isValidBranchName(String branchName)
Check if the given branch name is valid- Parameters:
branchName- branch name to check- Returns:
trueif the branch name is valid- Since:
- 5.0
-
setName
public CreateBranchCommand setName(String name)
Set the name of the new branch- Parameters:
name- the name of the new branch- Returns:
- this instance
-
setForce
public CreateBranchCommand setForce(boolean force)
Set whether to create the branch forcefully- Parameters:
force- iftrueand 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)
Set the start point- Parameters:
startPoint- corresponds to the start-point option; ifnull, the current HEAD will be used- Returns:
- this instance
-
setStartPoint
public CreateBranchCommand setStartPoint(RevCommit startPoint)
Set the start point- 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)
Set the upstream mode- Parameters:
mode- corresponds to the --track/--no-track/--set-upstream options; may benull- Returns:
- this instance
-
-