code: public void checkout(String branch) throws Exception {
          if (!branch.equals(getBranch())) {
              createBranchIfNeeded(branch);
              git.checkout().setName(branch).setStartPoint("origin/" + branch)
                  .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK).call();
              // for some reason jgit needs this when branch is switched
              git.checkout().setName(branch).call();
          }
      }
docs: Does not do anything if already on target branch.