Git won't add modified file

Starkers picture Starkers · Sep 26, 2014 · Viewed 32.9k times · Source

No idea why this is happening:

git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)

    modified:   file (modified content)

no changes added to commit (use "git add" and/or "git commit -a")
starkers@ubuntu:~/Documents/currentWork/protection_demo$ git add --all
starkers@ubuntu:~/Documents/currentWork/protection_demo$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)

    modified:   file (modified content)

No matter what I do, git commit -am, git commit -a the file will not be added to the commit. Any help?

Answer

palazzo train picture palazzo train · Sep 26, 2014

I think maybe Jubobs' comment is correct. Is your "file" a submodule?

This line (commit or discard the untracked or modified content in submodules) should not appear for normal files.

Here is what I get from git status:

$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   README.txt

no changes added to commit (use "git add" and/or "git commit -a")

You will not see (commit or discard the untracked or modified content in submodules) and (modified content) after my README.txt

So you may need to do what git recommended, work on the content in submodules.

Edit: Previously I thought the "git add ." could solve the issue but now I think it could not.