Package org.eclipse.jgit.api

## Class PushCommand

- java.lang.Object
- - org.eclipse.jgit.api.GitCommand<T>
  - - org.eclipse.jgit.api.TransportCommand<PushCommand,​Iterable<PushResult>>
    - - org.eclipse.jgit.api.PushCommand

All Implemented Interfaces:
  `Callable<Iterable<PushResult>>`

    public class PushCommand
    extends TransportCommand<PushCommand,​Iterable<PushResult>>

A class used to execute a `Push` command. It has setters for all supported options and arguments of this command and a `call()` method to finally execute the command.

See Also:
  Git documentation about Push

### Field Summary

### Fields inherited from class org.eclipse.jgit.api.TransportCommand

`credentialsProvider, timeout, transportConfigCallback`

### Fields inherited from class org.eclipse.jgit.api.GitCommand

`repo`

### Constructor Summary

Constructors
`protected` `PushCommand​(Repository repo)`

### Method Summary

All Methods Instance Methods Concrete Methods
`PushCommand` `add​(String nameOrSpec)` Add a reference to push.
`PushCommand` `add​(Ref ref)` Add a reference to push.
`Iterable<PushResult>` `call()` Executes the `push` command with all the options and parameters collected by the setter methods of this class.
`ProgressMonitor` `getProgressMonitor()`
`String` `getReceivePack()`
`List<RefSpec>` `getRefSpecs()`
`String` `getRemote()`
`int` `getTimeout()`
`boolean` `isDryRun()`
`boolean` `isForce()`
`boolean` `isThin()`
`PushCommand` `setDryRun​(boolean dryRun)` Sets whether the push operation should be a dry run
`PushCommand` `setForce​(boolean force)` Sets the force preference for push operation.
`PushCommand` `setOutputStream​(OutputStream out)` Sets the output stream to write sideband messages to
`PushCommand` `setProgressMonitor​(ProgressMonitor monitor)` The progress monitor associated with the push operation.
`PushCommand` `setPushAll()` Push all branches under refs/heads/*.
`PushCommand` `setPushTags()` Push all tags under refs/tags/*.
`PushCommand` `setReceivePack​(String receivePack)` The remote executable providing receive-pack service for pack transports.
`PushCommand` `setRefSpecs​(List<RefSpec> specs)` The ref specs to be used in the push operation
`PushCommand` `setRefSpecs​(RefSpec... specs)` The ref specs to be used in the push operation
`PushCommand` `setRemote​(String remote)` The remote (uri or name) used for the push operation.
`PushCommand` `setThin​(boolean thin)` Sets the thin-pack preference for push operation.

### Methods inherited from class org.eclipse.jgit.api.TransportCommand

`configure, configure, self, setCredentialsProvider, setTimeout, setTransportConfigCallback`

### Methods inherited from class org.eclipse.jgit.api.GitCommand

`checkCallable, getRepository, setCallable`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### PushCommand

    protected PushCommand​(Repository repo)

Parameters:
  `repo` -

### Method Detail

#### call

    public Iterable<PushResult> call()
                              throws GitAPIException,
                                     InvalidRemoteException,
                                     TransportException

Executes the `push` command with all the options and parameters collected by the setter methods of this class. Each instance of this class should only be used for one invocation of the command (means: one call to `call()`)

Specified by:
  `call` in interface `Callable<Iterable<PushResult>>`
Specified by:
  `call` in class `GitCommand<Iterable<PushResult>>`
Returns:
  an iteration over `PushResult` objects
Throws:
  `InvalidRemoteException` - when called with an invalid remote uri
  `TransportException` - when an error occurs with the transport
  `GitAPIException`

#### setRemote

    public PushCommand setRemote​(String remote)

The remote (uri or name) used for the push operation. If no remote is set, the default value of `Constants.DEFAULT_REMOTE_NAME` will be used.

Parameters:
  `remote` -
Returns:
  `this`
See Also:
  `Constants.DEFAULT_REMOTE_NAME`

#### getRemote

    public String getRemote()

Returns:
  the remote used for the remote operation

#### setReceivePack

    public PushCommand setReceivePack​(String receivePack)

The remote executable providing receive-pack service for pack transports. If no receive-pack is set, the default value of `RemoteConfig.DEFAULT_RECEIVE_PACK` will be used.

Parameters:
  `receivePack` -
Returns:
  `this`
See Also:
  `RemoteConfig.DEFAULT_RECEIVE_PACK`

#### getReceivePack

    public String getReceivePack()

Returns:
  the receive-pack used for the remote operation

#### getTimeout

    public int getTimeout()

Returns:
  the timeout used for the push operation

#### getProgressMonitor

    public ProgressMonitor getProgressMonitor()

Returns:
  the progress monitor for the push operation

#### setProgressMonitor

    public PushCommand setProgressMonitor​(ProgressMonitor monitor)

The progress monitor associated with the push operation. By default, this is set to `NullProgressMonitor`

Parameters:
  `monitor` -
Returns:
  `this`
See Also:
  `NullProgressMonitor`

#### getRefSpecs

    public List<RefSpec> getRefSpecs()

Returns:
  the ref specs

#### setRefSpecs

    public PushCommand setRefSpecs​(RefSpec... specs)

The ref specs to be used in the push operation

Parameters:
  `specs` -
Returns:
  `this`

#### setRefSpecs

    public PushCommand setRefSpecs​(List<RefSpec> specs)

The ref specs to be used in the push operation

Parameters:
  `specs` -
Returns:
  `this`

#### setPushAll

    public PushCommand setPushAll()

Push all branches under refs/heads/*.

Returns:
  {code this}

#### setPushTags

    public PushCommand setPushTags()

Push all tags under refs/tags/*.

Returns:
  {code this}

#### add

    public PushCommand add​(Ref ref)

Add a reference to push.

Parameters:
  `ref` - the source reference. The remote name will match.
Returns:
  `this`.

#### add

    public PushCommand add​(String nameOrSpec)

Add a reference to push.

Parameters:
  `nameOrSpec` - any reference name, or a reference specification.
Returns:
  `this`.
Throws:
  `JGitInternalException` - the reference name cannot be resolved.

#### isDryRun

    public boolean isDryRun()

Returns:
  the dry run preference for the push operation

#### setDryRun

    public PushCommand setDryRun​(boolean dryRun)

Sets whether the push operation should be a dry run

Parameters:
  `dryRun` -
Returns:
  `this`

#### isThin

    public boolean isThin()

Returns:
  the thin-pack preference for push operation

#### setThin

    public PushCommand setThin​(boolean thin)

Sets the thin-pack preference for push operation. Default setting is Transport.DEFAULT_PUSH_THIN

Parameters:
  `thin` -
Returns:
  `this`

#### isForce

    public boolean isForce()

Returns:
  the force preference for push operation

#### setForce

    public PushCommand setForce​(boolean force)

Sets the force preference for push operation.

Parameters:
  `force` -
Returns:
  `this`

#### setOutputStream

    public PushCommand setOutputStream​(OutputStream out)

Sets the output stream to write sideband messages to

Parameters:
  `out` -
Returns:
  `this`
Since:
  3.0