Package org.eclipse.jgit.api
Class CreateBranchCommand
Used to create a local branch.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
The modes available for setting up the upstream configuration (corresponding to the --set-upstream, --track, --no-track options -
Field Summary
FieldsFields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Constructor for CreateBranchCommand -
Method Summary
Modifier and TypeMethodDescriptioncall()
private ObjectId
private String
static boolean
isValidBranchName
(String branchName) Check if the given branch name is validprivate void
setForce
(boolean force) Set whether to create the branch forcefullySet the name of the new branchsetStartPoint
(String startPoint) Set the start pointsetStartPoint
(RevCommit startPoint) Set the start pointSet the upstream modeMethods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
Field Details
-
name
-
force
private boolean force -
upstreamMode
-
startPoint
-
startCommit
-
-
Constructor Details
-
CreateBranchCommand
Constructor for CreateBranchCommand- Parameters:
repo
- theRepository
-
-
Method Details
-
call
public Ref call() throws GitAPIException, RefAlreadyExistsException, RefNotFoundException, InvalidRefNameExceptionExecute the command
- Specified by:
call
in interfaceCallable<Ref>
- Specified by:
call
in classGitCommand<Ref>
- Throws:
GitAPIException
RefAlreadyExistsException
RefNotFoundException
InvalidRefNameException
-
getStartPointObjectId
private ObjectId getStartPointObjectId() throws AmbiguousObjectException, RefNotFoundException, IOException -
getStartPointOrHead
-
processOptions
- Throws:
InvalidRefNameException
-
isValidBranchName
Check if the given branch name is valid- Parameters:
branchName
- branch name to check- Returns:
true
if the branch name is valid- Since:
- 5.0
-
setName
Set the name of the new branch- Parameters:
name
- the name of the new branch- Returns:
- this instance
-
setForce
Set whether to create the branch forcefully- 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
Set the start point- Parameters:
startPoint
- corresponds to the start-point option; ifnull
, the current HEAD will be used- Returns:
- this instance
-
setStartPoint
Set the start point- Parameters:
startPoint
- corresponds to the start-point option; ifnull
, the current HEAD will be used- Returns:
- this instance
-
setUpstreamMode
Set the upstream mode- Parameters:
mode
- corresponds to the --track/--no-track/--set-upstream options; may benull
- Returns:
- this instance
-