开发者

Add files to git when directory already added

I know this is strange, because git shouldn't keep empty directories. This is what I did:

git add directory
git commit

In directory there are files, which I also want to add, but only some of them. However, none files were added, and I can't add any now.

When I clone repository to different location, I can clearly see that directory is empty.

When I try to add file in directory to git like this:

git add directory/file

I get an error fatal: Path 'directory/file' is in submodule 'directory'

How can I a开发者_运维问答dd this files?


This is not an empty directory, this is a submodule. Read ProGit: Submodules and man git-submoule on how to handle them.

Especially: If you clone a repository with submodules, you should init the submodules too

# git clone ...
git submodule init
git submodule update


As mentioned, this is a submodule. The empty directory needs to be in the containing (parent) repo. The submodule has it's own clone url.

On the clone, issue

git submodule update --init

And you're good to go (provided you have access to the clone url of the submodule)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜