OGeek|极客世界-中国程序员成长平台

标题: Is there a way to tell git-status to ignore the effects of .gitignore files? [打印本页]

作者: 菜鸟教程小白    时间: 2022-5-24 04:49
标题: Is there a way to tell git-status to ignore the effects of .gitignore files?

I have configured numerous .gitignore files to filter out many different unwanted files from a set of about 6,000 untracked files. I want to do git add . when I've got my filtered list looking the way I want it.

But, then I want to disable the .gitignore filters temporarily to see what got left behind, and make sure there was nothing important accidentally filtered.

I know that git-clean includes an option to ignore .gitignore files. Is there a similar option for git-status?

I could go through and delete all the .gitignore files, do the check, then restore them, but it seems there should be an easier way?



Best Answer-推荐答案


This option --ignored does the trick:

git status --ignored



(Update 1) I found the --ignored option alone doesn't work in certain git installations, perhaps it's a git bug. In those cases, an additional -s works for me:

git status -s --ignored

(Update 2) One user reported --ignored option is not supported in git version 1.7.0.4. My git version is 1.7.6. Another version 1.7.5.1 is the one that requires -s. You may try

git status -h

to see if --ignored is supported.






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://www.ogeek.cn/) Powered by Discuz! X3.4