.gitignore忽略文件的位置

时间:2014-03-14 00:27:07

标签: git gitignore

我在做

git add db/schema.rb
The following paths are ignored by one of your .gitignore files:
db/schema.rb
Use -f if you really want to add them.
fatal: no files added

我在哪里可以找到此文件被忽略,请参阅:

cat .gitignore
.project
nbproject
.redcar
cat ~/.gitignore
.idea

~/.gitignore用于全局忽略。

2 个答案:

答案 0 :(得分:5)

您可以使用git check-ignore在git repo中轻松查看当前使.gitignore规则忽略您的文件的规则(您必须拥有git 1.8.3.3 +):

cd /path/to/your/repo
git check-ignore -v -- path/to/your/file

-v - 详细 - 选项对于查看规则非常重要)

答案 1 :(得分:0)

我知道这是一个古老的问题,但这可能有助于某人。

如果我想查看我忽略的文件,我想知道.gitignore正在使它们被忽略'在我想知道这个信息的目录中,我运行这个命令:

# Finds ignored files recursively and shows what .gitignore is ignoring them
find . -type d -exec bash -c "git check-ignore -v {}/*" \;

另一种方式:

# Same as before but doesn't show errors for git check-ignore
find . -type d -exec bash -c "git check-ignore -v {}/*" 2>/dev/null \;
相关问题