code: public Ref checkoutBranch(Git git, String branch) {
          try {
              return git.checkout()
                  .setName(branch)
                  .call();
          } catch (GitAPIException e) {
              throw new IllegalStateException(e);
          }
      }
docs: Checkout existing branch.
  
  @param git
  instance.
  @param branch
  to move
  
  @return Ref to current branch