C.11 GitBranchTask

Create, move or delete repository branches. See official documentation (branch listing functionality is omitted in current implementation).

Table C.12: Attributes

NameTypeDescriptionDefaultRequired
gitPathStringPath to Git binary./usr/bin/gitNo
repositoryStringPath to Git repository.n/aYes
branchnameStringThe name of the branch to create or delete.n/aYes
newbranchStringThe new name for an existing branch.n/aYes, if branch move invoked
startpointStringThe new branch head will point to this commit. It may be given as a branch name, a commit-id, or a tag. If this option is omitted, the current HEAD will be used instead. See <start-point> argument of git-branch. No
setupstreamStringIf specified branch does not exist yet or if --force has been given, acts exactly like --track. Otherwise sets up configuration like --track would when creating the branch, except that where branch points to is not changed. See --set-upstream option of git-branch. No
trackBooleanSee --track option of git-branch.falseNo
notrackBooleanSee --no-track option of git-branch.falseNo
forceBooleanReset <branchname> to <startpoint> if <branchname> exists already. Without -f git branch refuses to change an existing branch.falseNo
moveBooleanMove/rename a branch and the corresponding reflog.falseNo
forcemoveBooleanMove/rename a branch even if the new branch name already exists.falseNo
deleteBooleanDelete a branch. The branch must be fully merged in its upstream branch, or in HEAD if no upstream was set with --track or --set-upstream.falseNo
forcedeleteBooleanDelete a branch irrespective of its merged status.falseNo

C.11.1 Example

<property name="repo.dir" value="./relative/path/to/repo" />
<resolvepath propertyName="repo.dir.resolved" file="${repo.dir}" />

<!-- Initialize normal repository -->
<gitinit repository="${repo.dir.resolved}" />

<!-- Create branch "sample-branch" tracking current HEAD -->
<gitbranch
    repository="${repo.dir.resolved}"
    branchname="sample-branch" />

<!--
Create branch "sample-branch" tracking origin/master
Note that you can omit both startpoint and track attributes in this case
-->
<gitbranch
    repository="${repo.dir.resolved}"
    branchname="sample-branch"
    startpoint="origin/master"
    track="true" />

<!-- Delete fully merged branch "sample-branch" -->
<gitbranch
    repository="${repo.dir.resolved}"
    branchname="sample-branch"
    delete="true" />

<!-- Force delete even unmerged branch "sample-branch" -->
<gitbranch
    repository="${repo.dir.resolved}"
    branchname="sample-branch"
    forcedelete="true" />

<!-- Renabe "branch1" to "branch2" -->
<gitbranch
    repository="${repo.dir.resolved}"
    branchname="branch1"
    newbranch="branch2"
    move="true" />