3

So this is a bit weird. I'm working on a Git repository, and everything is fine. Until I added a folder named "tests" to the repository using git add .. I noticed that no files were added like Git used to do.

So I pushed to Github to check if files where actually added or not, because "test" is figuring out in my "git status" log (but none of "tests" files).

I got a weird green icon, and this is the first time that I stumble across it. You can see the icon in the github repository.

The commit log shows the following

+Subproject commit 70b4cc379d0e1e749085ec1b3aaa0dd1cd0fc9b7

So what does the icon mean and what did exactly happen?

Edit: I didn't add a submodule, and if there is one, there should have been a ".gitmodules" file created to track them. My guess is that Git got confused even though it shouldn't.

The cure was simple

git rm tests --cached
git add tests
git commit -m "fixed!"
3
  • The test folder was empty when you first added it in git? Commented May 8, 2013 at 16:34
  • No, it already had all the files. Actually, I didn't know Git add empty folders. Commented May 8, 2013 at 16:35
  • It don't, that's why i asked. You said that you added the folder, but no files were added, so i thought it could be empty. But that's not the case =) Commented May 8, 2013 at 16:37

3 Answers 3

1

As radium pointed out, you've added a new git submodule.

The last line in the output of git show confirms that you added a new subproject:

$ git show a068b76
commit a068b7629f29f8774db67a7384dbeee732a89adb
Author:
Date:   Wed May 8 17:18:47 2013 +0100

    Unit testing

diff --git a/.gitignore b/.gitignore
index d56bef9..30d9aa6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
 .idea/
 .gitignore
+tests/wp-tests-config.php
diff --git a/tests b/tests
new file mode 160000
index 0000000..70b4cc3
--- /dev/null
+++ b/tests
@@ -0,0 +1 @@
+Subproject commit 70b4cc379d0e1e749085ec1b3aaa0dd1cd0fc9b7

By any chance did you run git submodule add <URL> tests but forgot to add the file .gitmodules which was created, into git's version control ?

If you add a directory with a .git directory, git is merely going to ignore the .git and add all other files inside it. It will not create a new Subproject commit unless you explicitly ask it to create a new submodule.

Sign up to request clarification or add additional context in comments.

1 Comment

No, I even checked the terminal history. I used the usual "git add ."
1

That icon is Github's way of indicating that the folder is a Git submodule. Maybe have a look at your module configuration within Git to find out why it is setup that way.

1 Comment

Most likely, as the folder was another Git repository. I'll read that page and see what I can do about it.
0

Use git add -u command to add newly created files / directories into git repo.

1 Comment

nope, the files weren't tracked to begin; look at radium answer, it's not about adding files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.