Package org.eclipse.jgit.api
Class RenameBranchCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<Ref>
-
- org.eclipse.jgit.api.RenameBranchCommand
-
public class RenameBranchCommand extends GitCommand<Ref>
Used to rename branches.- See Also:
- Git documentation about Branch
-
-
Field Summary
-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RenameBranchCommand(Repository repo)
Constructor for RenameBranchCommand.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Ref
call()
RenameBranchCommand
setNewName(String newName)
Sets the new short name of the branch.RenameBranchCommand
setOldName(String oldName)
Sets the old name of the branch.-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Constructor Detail
-
RenameBranchCommand
protected RenameBranchCommand(Repository repo)
Constructor for RenameBranchCommand.
- Parameters:
repo
- theRepository
-
-
Method Detail
-
call
public Ref call() throws GitAPIException, RefNotFoundException, InvalidRefNameException, RefAlreadyExistsException, DetachedHeadException
Execute the command
- Specified by:
call
in interfaceCallable<Ref>
- Specified by:
call
in classGitCommand<Ref>
- Throws:
GitAPIException
RefNotFoundException
InvalidRefNameException
RefAlreadyExistsException
DetachedHeadException
-
setNewName
public RenameBranchCommand setNewName(String newName)
Sets the new short name of the branch.The full name is constructed using the prefix of the branch to be renamed defined by either
setOldName(String)
or HEAD. If that old branch is a local branch, the renamed branch also will be, and if the old branch is a remote branch, so will be the renamed branch.- Parameters:
newName
- the new name- Returns:
- this instance
-
setOldName
public RenameBranchCommand setOldName(String oldName)
Sets the old name of the branch.oldName
may be a short or a full name. Using a full name is recommended to unambiguously identify the branch to be renamed.- Parameters:
oldName
- the name of the branch to rename; if not set, the currently checked out branch (if any) will be renamed- Returns:
- this instance
-
-