Package org.eclipse.jgit.api
Class RmCommand
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
Only remove files from index, not from working directoryprivate Collection
<String> Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
Field Details
-
filepatterns
-
cached
private boolean cachedOnly remove files from index, not from working directory
-
-
Constructor Details
-
RmCommand
Constructor for RmCommand.- Parameters:
repo
- theRepository
-
-
Method Details
-
addFilepattern
Add file name pattern of files to be removed- Parameters:
filepattern
- repository-relative path of file to remove (with/
as separator)- Returns:
this
-
setCached
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
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.- Specified by:
call
in interfaceCallable<DirCache>
- Specified by:
call
in classGitCommand<DirCache>
- Throws:
GitAPIException
NoFilepatternException
-
delete
-