简体   繁体   中英

Why is git adding my directories as though they were files?

It might be a lack of coffee, but I've just had some, so I'll go ahead and ask anyway.

Here's a literal talk that I had with my terminal, with line breaks for readability.

$ ls -la
total 28
drwxr-xr-x   5 thomas thomas  4096 2010-10-02 09:32 .
drwxr-xr-x 153 thomas thomas 12288 2010-10-02 09:30 ..
drwxr-xr-x   5 thomas thomas  4096 2010-10-02 09:31 content
drwxr-xr-x   3 thomas thomas  4096 2010-10-02 09:31 template
drwxr-xr-x   7 thomas thomas  4096 2010-10-02 09:31 typely

$ git --version
git version 1.7.0.4

$ git init .
Initialized empty Git repository in /home/thomas/typely/.git/

$ git add -A

$ git st
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#   new file:   content
#   new file:   template
#   new file:   typely
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   content
#   modified:   typely
#

But these are all directories! Also, they have not been modified since I added them.

Thinking that something might be wrong with the directories, I tried cp -r to a new directory, but the same thing happens. If I git add the files directly, git doesn't complain, but they don't show up in git st either.

Am I losing my mind?

Found it. These directories all contained separate git repositories!

$ find -name .git
./content/.git
./template/.git
./typely/.git

I'm leaving the question here in case anyone else ever runs into this problem.

They are being treated as submodules , which Git stores in the superrepository as a special kind of text files. Doing git diff when they are modified will show them as files containing the text Subproject commit plus a commit SHA1 ID.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM