1

Synopsis: git status gives

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

modified: < folder name > (modified content, untracked content)

In case:

  • 'git add' does not change the situation
  • You are looking for a way to commit the untracked content

What is the right way to fix that?

There is a related question here: How to track untracked content?, A simple answer to the common problem is hiding at the second, non accepted answer. Hope this thread would add clarity.

Nir
  • 1,618
  • 16
  • 24
  • 2
    Do you have a question? Why did you created this question? – alberand Feb 27 '19 at 10:17
  • I would like to document that knowledge in public so that others can find it later, more easily: https://stackoverflow.com/help/self-answer – Nir Feb 27 '19 at 10:20
  • The error does tell you what to do. – evolutionxbox Feb 27 '19 at 11:57
  • @evolutionxbox, 'commit or discard the untracked or modified content in submodules' can be definitely further explained; this is exactly what this thread does. – Nir Feb 27 '19 at 12:07
  • Yes, but it's unclear as there are two other reasons why changes might not be staged for committing. Perhaps mention that specifically in the question? – evolutionxbox Feb 27 '19 at 12:15
  • Thanks @evolutionxbox, I edited the question, hope it is more clear now. – Nir Feb 27 '19 at 12:35
  • I answered a very similar question at https://stackoverflow.com/q/54907159/1256452 – torek Feb 27 '19 at 17:54

1 Answers1

3

A common reason for the problem:

An unrelated git repository (".git" folder) in a subfolder, prevents the main git repository from tracking the subfolder.

There are two possible solutions:

1) Simple fix: using only the main repository - delete the ".git" folder in the 'problematic' subfolder
Take care not to delete the .git folder of the main repository, if possible copy what you intend to delete locally as a backup - just in case
[This idea had been suggested by @neoneye here How to track untracked content? ]

2) Using sub-module: Using git sub-module might be the solution you want. To get informed about this option you might find the related article https://medium.com/@porteneuve/mastering-git-submodules-34c65e940407 very useful.

Nir
  • 1,618
  • 16
  • 24