public static Ref checkout(Git git, String remote, boolean createBranch, SetupUpstreamMode mode, boolean force)
throws JGitInternalException,
RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException
{
CheckoutCommand checkout = git.checkout();
checkout.setCreateBranch(createBranch);
checkout.setName(remote);
checkout.setForce(force);
checkout.setUpstreamMode(mode);
return checkout.call();
}