How to tell if a file is git tracked (by shell exit code)?

后端 未结 8 2144
刺人心
刺人心 2020-11-28 17:24

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?

8条回答
  •  萌比男神i
    2020-11-28 18:18

    Just my two cents:

    git ls-files | grep -x relative/path

    where relative/path can be easily determined by pressing tab within an auto-completion shell. Add an additional | wc -l to get a 1 or 0 output.

提交回复
热议问题