code: public Iterable<PushResult> pushToRepository(Git git, String remote, String passphrase, Path privateKey) {
          SshSessionFactory sshSessionFactory = new JschConfigSessionFactory() {
              @Override
              protected void configure(OpenSshConfig.Host host, Session session) {
                  session.setUserInfo(new PassphraseUserInfo(passphrase));
              }
  
              @Override
              protected JSch createDefaultJSch(FS fs) throws JSchException {
                  if (privateKey != null) {
                      JSch defaultJSch = super.createDefaultJSch(fs);
                      defaultJSch.addIdentity(privateKey.toFile().getAbsolutePath());
                      return defaultJSch;
                  } else {
                      return super.createDefaultJSch(fs);
                  }
              }
          };
  
          try {
              return git.push()
                  .setRemote(remote)
                  .setPushAll()
                  .setPushTags()
                  .setTransportConfigCallback(transport -> {
                      SshTransport sshTransport = (SshTransport) transport;
                      sshTransport.setSshSessionFactory(sshSessionFactory);
                  })
                  .call();
          } catch (GitAPIException e) {
              throw new IllegalStateException(e);
          }
      }
docs: Push all changes and tags to given remote.
  
  @param git
  instance.
  @param remote
  to be used.
  @param passphrase
  to access private key.
  @param privateKey
  file location.
  
  @return List of all results of given push.