{"thread":{"id":"47262","subject":"Bad interaction between git clean, gitignore, and deleted submodules","startedAt":"2017-11-21T00:02:33Z","lastAt":"2017-11-21T00:02:33Z","messageCount":1,"participants":["Craig Silverstein"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"333025","messageId":"CAGXKyzEbDxBkHeeiZAreGJDmoGR2quPi26R_COWnno_3-EcnmA@mail.gmail.com","threadId":"47262","inReplyTo":null,"subject":"Bad interaction between git clean, gitignore, and deleted submodules","fromName":"Craig Silverstein","fromEmail":"csilvers@khanacademy.org","sentAt":"2017-11-21T00:02:25Z","receivedAt":"2017-11-21T00:02:33Z","isPatch":false,"sender":{"key":"csilvers@khanacademy.org","avatar":null},"body":"We have the following situation:\n1) A .gitignore file that contains '*.pyc'\n2) A repo with a submodule named jinja2\n\nIn normal use, clients of our repo have it checked out and run things\nin it, creating files like jinja2/run.pyc.\n\nI deleted the jinja2 submodule (by running `git rm jinja2` and\npushing).  Clients did a `git pull; git submodule update` and saw that\nthe jinja2 directory was still around, albeit untracked. So they ran\n`git clean -ffd`.\n\nThe problem is that git clean refuses to delete the directory due to\nthe (ignored and thus uncleanable) file jinja2/run.pyc.  And when it\nrefuses to delete the directory, it also leaves around jinja2/.git.\n\nLater, someone ran `git add .` and jinja2/.git got added back in as an\n\"orphaned submodule\" (I forget the exact terminology).  I know there's\na very loud warning when this happens but somehow they didn't see it,\nand it caused all sorts of trouble when they pushed their change.\n\nMy question: is it possible for a client to *really* get rid of the\njinja2 submodule?  We can't run `git clean -ffdx` because there are\nother .gitignore'd files we want to keep around.\n\nThe behavior I'd like to see is for `git clean -ffd` to delete .git\nfiles if they don't correspond to a currently registered submodule.\nThen `git clean -ffd` would delete jinja2/.git even though it leaves\naround jinja2/run.pyc.  But I don't know if that would break anything\nelse.\n\nOr maybe we should just add `.git` to our `.gitignore`, so people who\nrun `git add .` can't create these orphaned submodules...\n\ncraig\n"}]}