84

Can anyone please tell me why i have the grey icon when i push my files to github ? In side the app directory, there should be models, views , and controllers but in the remote GitHub I can't click in.

enter image description here

BC2
  • 1,129
  • 1
  • 11
  • 22

8 Answers8

76
git rm --cached <folder_name>

Then go to the parent directory and do:

git add .
git commit -m "<your_message>"
git push --all
Ankit Agrawal
  • 811
  • 1
  • 7
  • 3
30

It looks like you created a submodule, pointing to an unreachable remote location.

See this answer. That icon, when green, will point to the sub module. I'm assuming it's greyed out in your case because the sub module was incorrectly configured.

Given that .gitmodules is not present, it must have been deleted, leaving a sub module without a remote information.

If go into app and type git remote -v you will see where this module is pointing too. This place is currently unreachable.

In a similar scenario, I added a submodule and deleted .gitmodules. The result on GitHub looks like this:

missing sub module

Community
  • 1
  • 1
Boj
  • 3,923
  • 3
  • 22
  • 39
  • when i tried git submodule update --init it returns me no submodule mapping found in gitmodules for path 'app' – BC2 Oct 25 '13 at 08:51
  • I tried git ls-tree --full-tree -r HEAD and it returns me 100644 blob 6628083525c40f2abab01a69c4599d38380b18a5 Rakefile 160000 commit 60b600031853f5f4bbc0a2885caf5085bbf873fc app – BC2 Oct 25 '13 at 08:53
  • every directories are with the word blob except app ... n there isn't any further directory files in app... whereas in my actual project inside app, there is still a few directories like Model , View , Controller and etc – BC2 Oct 25 '13 at 08:53
  • what does `cat .gitmodules` return? Do not post actual URLs – Boj Oct 25 '13 at 08:55
  • cat: .gitmodules: No such file or directory – BC2 Oct 25 '13 at 08:59
  • .gitmodules was probably deleted. See updated answer. – Boj Oct 25 '13 at 09:29
  • the command git remote -v doesn't return me anything on the terminal :(... If gitmodules is delted what should i do ? – BC2 Oct 25 '13 at 09:36
  • Hey Will thanks for the help =) .... Somehow playing around with git init after typing git remote getting no result i tried git init again from step1 and everything works fine now. THanks =) – BC2 Oct 25 '13 at 10:00
  • What if the submodule was created unintentionally. How to fix the problem in that case? – Raffi Khatchadourian Apr 28 '15 at 19:11
28

Git thinks it's a submodule as it has a .git directory inside it. To fix...

Changed directory to the offending dir:

cd <offending git submodule>

Remove the .git directory inside it:

rm -rf .git

Update the git cache:

git rm --cached <offending git submodule>

Go to the parent directory:

cd ..

Add the directory to git:

git add .
git commit -m "Changed submodule to directory"
git push --all
sadfasdf
  • 289
  • 3
  • 2
20

It looks like you initialized git inside the folder. Delete the git file (rm -rf) from the subfolder and create a new repo and re initialize git.

Cockers
  • 217
  • 2
  • 2
  • 3
    Very concise answer! I just went in, enabled hidden files, deleted the hidden git folder inside of my project, and re-uploaded -- the grey folders icon is now gone and all is good again on github. Thanks for the concise and straightforward answer. – twknab Oct 21 '16 at 05:18
1

You have already initialized git inside the app directory and it can't find the remote. Delete the .git file inside app..

[app(master)]$ sudo rm -r .git

Or show the hidden files inside the folder and do it manually. Then re-commit & re-push the changes of the parent folder

Simon Somlai
  • 856
  • 8
  • 16
1

The easiest method I found was simply to remove the folder from local and update the remote repo. Navigate to your local directory and cut the folder containing the incorrectly set up .git subfolder to another location (outside the local repo, eg desktop) so you can correct the issue and copy back in later, then run:

git submodule update

git add --all

git commit --all

git push

This should remove the folder that is greyed out on the remote repo. Then copy the folder back in again in your local files and run the add --all commit --all git push as above, taking care of course first to delete the incorrectly set up .git folder from the subfolder beforehand to avoid the same issue again; to locate this on linux systems use cntrl-h from within the folder to view hidden files in your folders, you'll see a .git folder present in a subfolder that is causing the issue, simply delete that and that should resolve

Leigh Mathieson
  • 1,658
  • 2
  • 17
  • 25
0

It already has a .git inside it and hence appears grey. i.e it has git initialized inside it as well.

nmal
  • 21
  • 5
  • In my case this was actually the problem as I had a .git folder inside the folder and then it seems to create a submodule automatically for the folder. I am not sure why this answer is marked down? – leoncc Apr 22 '18 at 12:03
-1

In my case I had initialized a git repository in the root folder (the one that has manage.py) when deploying to Heroku before setting up a Git repository in the parent folder of the project.

When I then created a new repo in the project's parent folder, the root folder handling the models views and controllers was grayed out. The following worked for me:

  1. Delete parent folder repo
  2. Create new repo without checking "Initialize this repository with a README" since we will be importing the existing repository.
  3. Within your root folder the one with manage.py, do the following :

    git remote add origin "github repo link"

    git push -u origin master

  4. Refresh your Github repo and all your directories should be present