我知道如何创建简单的别名,但是有一个非常有用的命令可以从磁盘中取消暂存已删除的文件,但我无法使其工作。
git rm $(git ls-files --deleted)
(从这里Removing multiple files from a Git repo that has been removed from disk)
我试过:
git config --global alias.cleandeleted 'rm $(git ls-files --deleted)'
Run Code Online (Sandbox Code Playgroud)
但是当我写:
git cleandeleted
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
error: unknown option `deleted)'
usage: git rm [options] [--] <file>...
-n, --dry-run dry run
-q, --quiet do not list removed files
--cached only remove from the index
-f, --force override the up-to-date check
-r allow recursive removal
--ignore-unmatch exit with a zero status even if nothing matched
Run Code Online (Sandbox Code Playgroud)
问题是$(...). 正如你定义的那样,git 只处理 git intern 命令,不知道如何处理$(...).
有一个技巧可以让你指挥工作:
git config --global alias.cleandeleted '!git rm $(git ls-files --deleted)'
Run Code Online (Sandbox Code Playgroud)
由于!别名的作用就像命令直接提供给命令行一样。
| 归档时间: |
|
| 查看次数: |
1158 次 |
| 最近记录: |