PARTIAL UNDO
Description
Undoes changes in a workspace.
Usage
cm partial undo [<path>[ ...]] [--symlink] [-r | --recursive] [<filter>[ ...]] [--silent | --machinereadable [--startlineseparator=<sep>] [--endlineseparator=<sep>] [--fieldseparator=<sep>]]
Options
Option / Argument | Description |
---|---|
--symlink | Applies the undo operation to the symlink and not to the target. |
-r | --recursive | Executes the undo recursively. |
--silent | Does not show any output. |
--machinereadable | Outputs the result in an easy-to-parse format. |
--startlineseparator | Used with the '--machinereadable' flag, specifies how the lines should start. |
--endlineseparator | Used with the '--machinereadable' flag, specifies how the lines should end. |
--fieldseparator | Used with the '--machinereadable' flag, specifies how the fields should be separated. |
--checkedout | Select checked-out files and directories. |
--unchanged | Select files whose content is unchanged. |
--changed | Select locally changed or checked-out files and directories. |
--deleted | Select deleted files and directories. |
--moved | Select moved files and directories. |
--added | Select added files and directories. |
path | Path of the files or directories to apply the operation to. Use double quotes (" ") to specify paths containing spaces. Use a whitespace to separate paths. If no path is specified, by default the undo operation will take all of the files in the current directory. |
filter | Applies the specified filter or filters to the given paths. Use a whitespace to separate filters. See the Filters section for more information. |
Help
Remarks
The undo command is dangerous - it undoes work in an irreversible way. Once the undo has finished, it is not possible to recover the previous state of the files and directories affected by it. If no path is specified in the arguments, by default it will undo every change in the current directory, but not recursively.
These are equivalent when executed from the /src directory
- src
- file.txt
- code.cs
- /test
- test_a.py
- test_b.py
cm partial undo
cm partial undo *
cm partial undo file.txt code.cs /test
cm partial undo .
cm partial undo /src file.txt code.cs
If you want the operation to be recursive, you must specify the '-r' flag.
To undo all of the changes below a directory (including changes affecting the directory itself):
cm partial undo dirpath -r
If dirpath is a workspace path, every change in the workspace will be undone.
Filters
If no flag is specified, by default, all changes are undone, but the paths can be filtered using one or more of the flags below. If a file or directory matches one or more of the specified kinds of change, all of the changes on said file or directory will be undone. For example, if you specify both '--checkedout' and '--moved', if a file is both checkedout and moved, both changes will be undone.
Examples
cm partial undo . -r
(Undoes all changes in the current directory recursively. If executed from the workspace's root, undoes all changes in the entire workspace.)
cm partial co file.txt
cm partial undo file.txt
(Undoes the checkout on file.txt.)
echo content >> file.txt
cm partial undo file.txt
(Undoes the local change to file.txt.)
cm partial undo src
(Undoes changes to the src directory and its files.)
cm partial undo src/*
(Undo changes in every file and directory contained in src, without affecting src.)
cm partial undo *.cs
(Undo changes to every file or directory that matches *.cs in the current directory.)
cm partial undo *.cs -r
(Undoes changes on every file or directory that matches *.cs in the current directory and every directory below it.)
cm partial co file1.txt file2.txt
echo content >> file1.txt
cm partial undo --unchanged
(Undoes the checkout of unchanged file2.txt, ignoring locally changed file1.txt.)
echo content >> file1.txt echo content >> file2.txt
cm partial co file1.txt
cm partial undo --checkedout
(Undoes the changes in checked-out file file1.txt, ignoring file2.txt as it is not checked-out.)
cm partial add file.txt
cm partial undo file.txt
(Undoes the add of file.txt, making it once again a private file.)
rm file1.txt echo content >> file2.txt
cm partial add file3.txt
cm partial undo --deleted --added *
(Undoes the file1.txt delete and file3.txt add, ignoring the file2.txt change.)