Top Description Fields Constructors Methods
org.eclipse.jgit.api

public Class RmCommand

extends GitCommand<DirCache>
Class Inheritance
Imports
java.io.File, .IOException, java.util.ArrayList, .Collection, .List, org.eclipse.jgit.api.errors.GitAPIException, .JGitInternalException, .NoFilepatternException, org.eclipse.jgit.dircache.DirCache, .DirCacheBuildIterator, .DirCacheBuilder, org.eclipse.jgit.events.WorkingTreeModifiedEvent, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.Constants, .FileMode, .Repository, org.eclipse.jgit.treewalk.TreeWalk, org.eclipse.jgit.treewalk.filter.PathFilterGroup

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 org.eclipse.jgit.api.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

Modifier and TypeField and Description
private boolean
cached

Only remove files from index, not from working directory

private Collection<String>
Inherited from org.eclipse.jgit.api.GitCommand:
repo

Constructor Summary

AccessConstructor and Description
public
RmCommand(Repository repo)

Constructor for RmCommand.

Method Summary

Modifier and TypeMethod and Description
public RmCommand

Returns:

this
addFilepattern
(String
repository-relative path of file to remove (with / as separator)
filepattern
)

Add file name pattern of files to be removed

public DirCache
call()

Implements abstract org.eclipse.jgit.api.GitCommand.call.

Implements java.util.concurrent.Callable.call.

Computes a result, or throws an exception if unable to do so.

private boolean
public RmCommand

Returns:

this
setCached
(boolean
true if files should only be removed from index, false if files should also be deleted from the working directory
cached
)

Only remove the specified files from the index.

Inherited from org.eclipse.jgit.api.GitCommand:
checkCallablegetRepositorysetCallable

Field Detail

cachedback to summary
private boolean cached

Only remove files from index, not from working directory

filepatternsback to summary
private Collection<String> filepatterns

Constructor Detail

RmCommandback to summary
public RmCommand(Repository repo)

Constructor for RmCommand.

Parameters
repo:Repository

the org.eclipse.jgit.lib.Repository

Method Detail

addFilepatternback to summary
public RmCommand addFilepattern(String filepattern)

Add file name pattern of files to be removed

Parameters
filepattern:String

repository-relative path of file to remove (with / as separator)

Returns:RmCommand

this

callback to summary
public DirCache call() throws GitAPIException, NoFilepatternException

Implements abstract org.eclipse.jgit.api.GitCommand.call.

Implements java.util.concurrent.Callable.call.

Doc from org.eclipse.jgit.api.GitCommand.call.

Computes a result, or throws an exception if unable to do so.

Execute the command

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.

Returns:DirCache

Doc from java.util.concurrent.Callable.call.

computed result

Annotations
@Override
deleteback to summary
private boolean delete(File p)
setCachedback to summary
public RmCommand setCached(boolean cached)

Only remove the specified files from the index.

Parameters
cached:boolean

true if files should only be removed from index, false if files should also be deleted from the working directory

Returns:RmCommand

this

Since
2.2