Nir
Nir

Reputation: 1874

Git: How to commit untracked content?

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:

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.

Upvotes: 1

Views: 2372

Answers (1)

Nir
Nir

Reputation: 1874

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.

Upvotes: 3

Related Questions