我有一个类似这样的结构:
projects/
.gitignore
foo/
some_file
bar/
another_file
foo
、bar
和projects
是git项目。在.gitignore
中,我写了*
(实际上我尝试过很多东西),但是当我在projects/foo
中运行git status
时,它仍然告诉我要添加some_file
。如果我正确地阅读了.gitignore
文档,它说Git应该在所有父文件夹中查找.gitignore
文件并使用它们。但是它似乎完全忽略了.gitignore
中的那个。这是怎么回事?我已经尝试了
git check-ignore
,但它好像根本不存在.gitignore
。复现步骤:
/ $ cd /tmp
/tmp $ mkdir projects
/tmp $ cd projects
/tmp/projects $ echo "*" > .gitignore
/tmp/projects $ git init
Initialized empty Git repository in /private/tmp/projects/.git/
/tmp/projects $ mkdir foo
/tmp/projects $ cd foo
/tmp/projects/foo $ git init
Initialized empty Git repository in /private/tmp/projects/foo/.git/
/tmp/projects/foo $ touch some_file
/tmp/projects/foo $ git status
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
some_file
nothing added to commit but untracked files present (use "git add" to track)
.git/
目录放在正确的位置吗? - iBug.git/
目录? - Timmmm