git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Bad interaction between git clean, gitignore, and deleted submodules

From
CSCraig Silverstein <csilvers@khanacademy.org>
Date
Nov 21, 2017, 00:02 UTC
Message-ID
<CAGXKyzEbDxBkHeeiZAreGJDmoGR2quPi26R_COWnno_3-EcnmA@mail.gmail.com>
We have the following situation:
1) A .gitignore file that contains '*.pyc'
2) A repo with a submodule named jinja2

In normal use, clients of our repo have it checked out and run things in it, creating files like jinja2/run.pyc.

I deleted the jinja2 submodule (by running `git rm jinja2` and pushing). Clients did a `git pull; git submodule update` and saw that the jinja2 directory was still around, albeit untracked. So they ran `git clean -ffd`.

The problem is that git clean refuses to delete the directory due to the (ignored and thus uncleanable) file jinja2/run.pyc. And when it refuses to delete the directory, it also leaves around jinja2/.git.

Later, someone ran `git add .` and jinja2/.git got added back in as an "orphaned submodule" (I forget the exact terminology). I know there's a very loud warning when this happens but somehow they didn't see it, and it caused all sorts of trouble when they pushed their change.

My question: is it possible for a client to *really* get rid of the jinja2 submodule? We can't run `git clean -ffdx` because there are other .gitignore'd files we want to keep around.

The behavior I'd like to see is for `git clean -ffd` to delete .git files if they don't correspond to a currently registered submodule. Then `git clean -ffd` would delete jinja2/.git even though it leaves around jinja2/run.pyc. But I don't know if that would break anything else.

Or maybe we should just add `.git` to our `.gitignore`, so people who run `git add .` can't create these orphaned submodules...

craig
Message 1 of 1 in “Bad interaction between git clean, gitignore, and deleted submodules”
  1. Craig SilversteinNov 21, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.