0

Solution here: Why does git say a sub project is dirty if I do not have any sub-modules in my repository?


So I'm following Michael Hartl's Rails tutorial. I'm about five chapters in when I realized my app isn't working on Heroku. I look back a little and I realize that my entire config/initializers folder isn't in my repo, as you can see here: https://github.com/ksin/sample_app/tree/master/config

Clearly, the folder exists in my workspace.

$git status #=> shows nothing to commit.

When I alter a file in initializers and run $git status, config/initializers appears as modified content. However, I can't stage the change at all. (As in I'll run $git add . but when I run $git status afterwards, the unstaged file is still there.)

I'm unsure what the problem is as this has never happened to me before.

After searching some more, I also did: $git submodule #=> No submodule mapping found in .gitmodules for path 'config/initializers'

Does this mean anything?

Community
  • 1
  • 1
supahken
  • 171
  • 9
  • possible duplicate of [Why does git say a sub project is dirty if I do not have any sub-modules in my repository?](http://stackoverflow.com/questions/9089515/why-does-git-say-a-sub-project-is-dirty-if-i-do-not-have-any-sub-modules-in-my-r) – Nevik Rehnel Mar 08 '14 at 16:42

2 Answers2

0

Did you tried to backup your initializer folder, delete it, and

 git rm initializers

It looks like, 'initializers' was initialized as subproject.

Vitalyp
  • 1,069
  • 1
  • 11
  • 20
  • In your static-pages branch you made Subproject commit. Check my comment at https://github.com/ksin/sample_app/commit/b0f5f00a2f9aed9e70fb795fc344c8af3e67a4bd#diff-67813f286af146a5e0defcc312d07726R1 – Vitalyp Mar 08 '14 at 04:50
  • I believe so too. I'm trying that now. – supahken Mar 08 '14 at 04:51
  • I actually don't recall doing anything that has to do with subproject commit. I literally just read and followed the tutorials instructions exactly. – supahken Mar 08 '14 at 04:52
  • I just re-added the initializers. The problem persists. When I stage the file, it comes up as 1 file changed, 1 insertion(+) create mode 160000 config/initializers – supahken Mar 08 '14 at 04:55
  • Ahhh I figured it out. Thanks man, your hint helped. I'd give you a +1 if I had enough reputation to. – supahken Mar 08 '14 at 05:06
  • How did you actually repeared this? ) – Vitalyp Mar 08 '14 at 05:13
0

Great! How you actually do it? How can I solve it in future? Just want to show you another trick: override the target directory, to use another for initializers:

 module SampleApp
    class Application < Rails::Application
      config.paths['config/initializers'] = Rails.root.join('bin', 'initializers')
      ...

Now, RAILS_ROOT/bin/initializers is yours..

Of course, it is very horrible, however if you need a quick fix right now, you can do this trick, and perform repairing later. :)

Vitalyp
  • 1,069
  • 1
  • 11
  • 20
  • 1
    Well it turned out there was another .git directory in the config/initializers directory for some reason. I have no idea when I created that or how it ended up there. That may or may not have something to do with subprojects/submodules. But once I deleted that .git, I was able to stage, commit, and push the initializers folder regularly no problem. – supahken Mar 08 '14 at 16:38