git ignoring a directory, it's like it doesn't exist

I have a cloned repo. There's a directory, call it a/b/c that used to be its own repo, ie there was a/b/c/.git/ etc.

Now I want the files managed in the main repo. I don't care about the history in a/b/c, so I deleted the .git dir in a/b/c

But the problem is that git status is ignoring a/b/c completely. I can't git add it. It's as though I'd put the path into .gitignore (I haven't).

Obviously before, it made sense for git to ignore a subdir with a .git dir in it, but now how does it know the difference?

Is there somewhere else that ignore files are listed other than .gitignore and .git/info/excludes? There's nothing in the .git/config file?

I've been asked what git status says. Not much:

/path/to/root/dir $ git status
# On branch fred
nothing to commit (working directory clean)

And what git add says. Even less (nothing)

/path/to/root/dir $ git add a/b/c

I have no idea what the problem was or how it arose (v. annoying), but here is how I fixed it, in case anyone else gets stuck:

git rm --cached a/b/c
git commit -m "removed phantom a/b/c dir"
git add a/b/c
git commit -m "finally able to add a/b/c"

Interestingly git log a/b/c only lists the "finally able..." commit. git show HEAD^ (the "removed phantom..." commit says

-Subproject commit c311ccdc91c8be66019aa138d1c4af49a6b7a81c

So it looks like it was treating it specially some how. I'm going to have to read up more on subprojects and/or submodules.


Do you have a global gitignore file ? (Check with git config core.excludesfile )


使用git add -f强制git添加它当前忽略的文件。

链接地址: http://www.djcxy.com/p/16466.html

上一篇: 使用Git管理大型二进制文件

下一篇: git忽略一个目录,就像它不存在一样