C.16 GitCheckoutTask

Checkout a branch or paths to the working tree. See official documentation.

Table C.17: Attributes

NameTypeDescriptionDefaultRequired
gitPathStringPath to Git binary/usr/bin/gitNo
repositoryStringPath to Git repositoryn/aYes
branchnameStringBranch to checkout. See <branch> in git-checkout.originNo
startpointStringThe name of a commit at which to start the new branch; Defaults to HEAD. See <start_point> in git-checkout. No
createBooleanCreate a new branch named <branchname> and start it at <startpoint>falseNo
forcecreateBooleanCreates the branch <branchname> and start it at <startpoint>; if it already exists, then reset it to <startpoint>. This is equivalent to running "git branch" with "-f".falseNo
mergeBooleanSee --merge in git-checkout.falseNo
trackBooleanSee --track in git-checkout.falseNo
notrackBooleanSee --no-track in git-checkout.falseNo
quietBooleanQuiet, suppress feedback messages. See --quiet in git-checkout.falseNo
forceBooleanWhen switching branches, proceed even if the index or the working tree differs from HEAD. This is used to throw away local changes. See --force in git-checkout.falseNo

C.16.1 Example

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

                <!-- clone repository -->
                <gitclone
                repository="git://github.com/path/to/repo/repo.git"
                targetPath="${repo.dir.resolved}" />

                <!-- create and switch to "mybranch" branch -->
                <gitcheckout
                repository="${repo.dir.resolved}"
                branchname="mybranch" quiet="true" create="true" />

                <!-- get back to "master" branch -->
                <gitcheckout
                repository="${repo.dir.resolved}"
                branchname="master" quiet="true" />

                <!-- create (force) already created branch -->
                <gitcheckout
                repository="${repo.dir.resolved}"
                branchname="mybranch" quiet="true"
                forceCreate="true" />