public void checkoutBranch(String branch, String commitish) throws GitException { verifyGitRepository(); try { // First, checkout to detached HEAD, so we can delete the branch. launchCommand("checkout", "-f", commitish); if (null != branch) { jGitDelegate.checkout() .setForce(true) .setStartPoint(commitish) .setName(branch) .setCreateBranch(true) .call(); } } catch (GitAPIException e) { throw new GitException(Messages.GitAPI_Branch_CheckoutErrorMsg(branch, commitish), e); } }