org.eclipse.jgit.api

## Class RmCommand

- java.lang.Object
- - org.eclipse.jgit.api.GitCommand<DirCache>
  - - org.eclipse.jgit.api.RmCommand

All Implemented Interfaces:
  Callable<DirCache>

    public class RmCommand
    extends GitCommand<DirCache>

Remove files from the index and working directory (or optionally only from the index).

It has setters for all supported options and arguments of this command and a `call()` method to finally execute the command. Each instance of this class should only be used for one invocation of the command (means: one call to `call()`).

Examples (`git` is a `Git` instance):

Remove file "test.txt" from both index and working directory:

     git.rm().addFilepattern("test.txt").call();

Remove file "new.txt" from the index (but not from the working directory):

     git.rm().setCached(true).addFilepattern("new.txt").call();

See Also:
  Git documentation about Rm

### Field Summary

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

`repo`

### Constructor Summary

Constructors
Constructor and Description
`RmCommand(Repository repo)`

### Method Summary

Methods
`RmCommand` `addFilepattern(String filepattern)`
`DirCache` `call()` Executes the `Rm` command.
`RmCommand` `setCached(boolean cached)` Only remove the specified files from the index.

### 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

#### RmCommand

    public RmCommand(Repository repo)

Parameters:
  `repo` -

### Method Detail

#### addFilepattern

    public RmCommand addFilepattern(String filepattern)

Parameters:
  `filepattern` - repository-relative path of file to remove (with `/` as separator)
Returns:
  `this`

#### setCached

    public RmCommand setCached(boolean cached)

Only remove the specified files from the index.

Parameters:
  `cached` - true if files should only be removed from index, false if files should also be deleted from the working directory
Returns:
  `this`
Since:
  2.2

#### call

    public DirCache call()
                  throws GitAPIException,
                         NoFilepatternException

Executes the `Rm` command. Each instance of this class should only be used for one invocation of the command. Don't call this method twice on an instance.

Specified by:
  `call` in interface `Callable<DirCache>`
Specified by:
  `call` in class `GitCommand<DirCache>`
Returns:
  the DirCache after Rm
Throws:
  `GitAPIException` - or subclass thereof when an error occurs
  `NoFilepatternException`