public class RmCommand extends GitCommand<DirCache>
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();
repo
Constructor and Description |
---|
RmCommand(Repository repo) |
Modifier and Type | Method and Description |
---|---|
RmCommand |
addFilepattern(String filepattern) |
DirCache |
call()
Executes the
Rm command. |
RmCommand |
setCached(boolean cached)
Only remove the specified files from the index.
|
checkCallable, getRepository, setCallable
public RmCommand(Repository repo)
repo
- public RmCommand addFilepattern(String filepattern)
filepattern
- repository-relative path of file to remove (with
/
as separator)this
public RmCommand setCached(boolean cached)
cached
- true if files should only be removed from index, false if
files should also be deleted from the working directorythis
public DirCache call() throws GitAPIException, NoFilepatternException
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.call
in interface Callable<DirCache>
call
in class GitCommand<DirCache>
GitAPIException
- or subclass thereof when an error occursNoFilepatternException
Copyright © 2017 Eclipse JGit Project. All rights reserved.