Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a folder content in Git

Tags:

git

github

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!"
like image 358
Omar Abid Avatar asked Feb 25 '26 23:02

Omar Abid


2 Answers

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.

like image 76
Tuxdude Avatar answered Feb 28 '26 13:02

Tuxdude


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.

like image 44
kenchilada Avatar answered Feb 28 '26 13:02

kenchilada



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!