Git accuses that ignored directory has modified content

Asked

Viewed 1,334 times

5

I have the directory contents in my file .gitignore, as follows:

app/dir/*

But when I give a git status, git accuses the following:

# 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:   app/dir (modified content, untracked content)
#
no changes added to commit (use "git add" and/or "git commit -a")

In my opinion, he should not even know or care if there is modified content within this directory, since it should be ignored. What this status means, and how to resolve it?

  • dir is a submodule? git status --ignore-submodules returns the same message?

  • Hm, I was sure it wasn’t a sobmodule (I don’t remember creating it), but running this command comes "Working directory clean"

  • Can I just delete the . git inside that directory? I just discovered that file there.

  • 1

    I would examine the contents of .git/config before deleting the directory. The section [submodule "app/dir"] should contain the url of where you cloned the content of dir. Here is the recipe for deleting a https://git.wiki.kernel.org/index.php/GitSubmoduleTutorial#Removal submodule

  • Thanks, @Marcosbanik. Don’t want to post this as an answer?

1 answer

3


This message may appear if dir is a sub-module of your repository. You can check this by running git submodule in your root repository.

In case you want to git status ignore the changes in app/dir execute git status --ignore-submodules.

If you prefer to remove the submodule, first investigate the content of app/dir/.git/config. If you still want to remove app/dir/.git you will also have to edit the files .git/config and .gitmodules from the root repository.

  • Just one observation: there was nothing connected to submodules in my .git/config, nor was there a file .gitmodules. I had to spin git rm --cached app/dir to remove the remaining garbage.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.