git - 如何判断文件是否被 git 跟踪(通过 shell 退出代码)?

标签 git

有没有办法通过运行一些 git 命令并检查其退出代码来判断文件是否正在被跟踪?

换句话说:git 是在跟踪一个文件吗?

最佳答案

尝试:

git ls-files --error-unmatch <file name>

如果文件未被跟踪,将以 1 退出

关于git - 如何判断文件是否被 git 跟踪(通过 shell 退出代码)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2405305/

相关文章:

Git 子模块 : Is it possible to notify other developers of a change?

windows - Windows 的 SourceTree 不工作

git - 如何在 SourceTree 中使用 VS Code 作为 merge 和差异工具?

Git - 如何查看一个分支是否曾经被 merge 到另一个分支?

git - 使 git diff 不打印到终端

python - 导入错误 : No module named git after reformatting laptop

git - 在 U 盘上使用 GIT 获取 "travelling code"

git - 恢复 merge 恢复

当前分支的 Git 别名

GIT:每个提交的标签是唯一的吗?