The [rm] Command
Remove files from the working tree and from the index
Usage
libra rm [OPTIONS] [PATHSPEC]...
Arguments
[PATHSPEC]...
- Files to remove.
A leading directory name can be given to remove all files in the directory, and recursively all sub-directories, but this requires the-r
option to be explicitly given.
Description
Remove files matching pathspec from the index, or from the working tree and the index. libra rm
will not remove a file from just your working
directory. (There is no option to remove a file only from the working tree and yet keep it in the index; use system rm if you want to do
that.)
Options
-
--cached
Use this option to unstage and remove paths only from the index. Working tree files, whether modified or not, will be left alone. -
--dry-run
Don't actually remove any files; instead just show if they exist in the index and would otherwise be removed by the command. This option is useful for previewing what files would be removed before actually executing the removal. It works with all other options (--cached
,--recursive
,--force
) to show exactly what the actual command would do. -
-r
,--recursive
Allow recursive removal when a leading directory name is given. -
-f
,--force
Force removal even if the specified paths are not tracked. This skips validation checks and deletes files or directories regardless of their index status.
Examples
Basic Usage
# Remove a file from both index and working tree
libra rm file.txt
# Remove multiple files
libra rm file1.txt file2.txt
Using --cached
# Remove from index only, keep in working tree
libra rm --cached file.txt
Using --dry-run
# Preview what would be removed
libra rm --dry-run file1.txt file2.txt
# Preview cached removal
libra rm --dry-run --cached *.txt
# Preview recursive directory removal
libra rm --dry-run -r old_directory/
The --dry-run
option will output something like:
Would remove the following:
rm 'file1.txt'
rm 'file2.txt'
Recursive Removal
# Remove entire directory recursively (preview first!)
libra rm --dry-run -r directory/
libra rm -r directory/