如何判断文件是否被git跟踪(通过shell退出代码)? [英] How to tell if a file is git tracked (by shell exit code)?

查看:316
本文介绍了如何判断文件是否被git跟踪(通过shell退出代码)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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


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

解决方案

试试:

  git ls-files --error-unmatch<文件名> 

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


Is there a way to tell if a file is being tracked by running some git command and checking its exit code?

In other words: is git tracking a file?

解决方案

try:

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

will exit with 1 if file is not tracked

这篇关于如何判断文件是否被git跟踪(通过shell退出代码)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆