1

I have a git repository online and I use, as many do, to keep track of my programs. It worked all fine with the usual procedure from the root of my directory's tree:

git add . 
git commit
git push origin master

When one day I found a subdirectory in my tree have become green (on the git site) and was impossible to access. Now I know the green color is for a submodule (even if I have not understood what this mean) but I'd like it to be a real directory, one where I can view and download what's there or examine modifications. The question is, how can I make this directory to become normal again, with all its subdirectory and file inside without touching the other directories inside the tree?

Thanks

Luigi Tiburzi
  • 4,265
  • 7
  • 32
  • 43

1 Answers1

2

The idea would be to:

The last link shows you how to dereference a submodule, while, if you want, preserving the history of the commits done in said submodule (but merging them back to the main repo)

Now if, when trying to init the submodule, you get the message:

No submodule mapping found in .gitmodules for path '...'

Check the second part of "Git - how to track untracked content?": the "Replace It with Plain Content" section.

The root cause is when you try to add a directory which is a git repo in itself within your main git repo work tree:

The directory 'nested repo' starts out as an independent Git repository.
Usually such sub-repositories are ignored, but if you tell git add to explicitly add it, then it will create an gitlink entry that points to the sub-repository’s HEAD commit instead of adding the contents of the directory.
It might be nice if git add would refuse to create such “semi-submodules”.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • The procedure outlined is not working, maybe for some error I'm doing. I get this when I execute point 2. No submodule mapping found in .gitmodules for path 'python' and same errors for point 3. as what I'm trying to remove/modify doesn't exist – Luigi Tiburzi Sep 09 '12 at 20:50
  • @LuigiTiburzi see my edited answer (which also explain why you suddenly see a green directory in your GitHub repo) – VonC Sep 09 '12 at 21:14
  • the problem is that even git rm --cached 'path' gave me errors as if the file doesn't exist. In fact I don't have any .gitsubmodules anywhere... – Luigi Tiburzi Sep 09 '12 at 21:24
  • this was the exact error I got when trying to follow the first step of your edited answer fatal: pathspec 'python2.7/networking/' did not match any files – Luigi Tiburzi Sep 09 '12 at 21:43
  • Excuse my bothering, now I'm arrived in some way to get things almost done, or at least I hope so, I have only one problem when I run git commit -a in the message my changes are under changes not staged for commit, how can I stage them? Git add is not working... – Luigi Tiburzi Sep 09 '12 at 22:12
  • All done!!! I deleted the .git inside all the directories interested, I was doing so only on the main branch though I still don't understand why git add wasn't working. Thank you for your help – Luigi Tiburzi Sep 09 '12 at 22:19