code: public PullResult pullFromRepository(Git git, String remote, String remoteBranch, String username, String password) {
          try {
              return git.pull()
                  .setRemote(remote)
                  .setRemoteBranchName(remoteBranch)
                  .setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password))
                  .call();
          } catch (GitAPIException e) {
              throw new IllegalStateException(e);
          }
      }
docs: Pull repository from current branch and remote branch with same name as current
  
  @param git
  instance.
  @param remote
  to be used.
  @param remoteBranch
  to use.
  @param username
  to connect
  @param password
  to connect