git rm -r some-file => 如果路径不存在,则 git 以 1 退出

标签 git bash

我正在寻找一种使用方法

git rm -r some-file some-folder

但如果路径/路径规范不存在,则避免以 1 退出。

我尝试使用 -f 选项,但似乎不起作用。

有人知道我怎样才能做到这一点吗?

最佳答案

使用--ignore-unmatch选项:

Exit with a zero status even if no files matched.

git rm -r --ignore-unmatch some-file some-folder

关于git rm -r some-file => 如果路径不存在,则 git 以 1 退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37893967/

相关文章:

git - git clone 中 --single-branch 的目的?

GitHub 添加用户以在 repo 上一起工作......?

git - 如何使用 TortoiseGit 进行推送

bash - 以从特定数字开始递增的数字重命名文件

git - 使用具有非标准端口的远程存储库

regex - 如何从 bash 中的字符串中提取值?

linux - bash 脚本问题 - 将特定单词移动到行中的另一个位置

linux - 想要在 grep 中只获得匹配项

macos - 为符号链接(symbolic link)设置图标

git - PowerShell 脚本未捕获 git 输出