{"thread":{"id":"53582","subject":"add -u stages submodule changes when ignore=all is set","startedAt":"2020-05-29T21:33:48Z","lastAt":"2020-05-29T21:33:48Z","messageCount":1,"participants":["Crockett, Eric"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"398907","messageId":"f60c88d8ec2e4efcbbf4f78fd8f87da6@EX13D20UWA002.ant.amazon.com","threadId":"53582","inReplyTo":null,"subject":"add -u stages submodule changes when ignore=all is set","fromName":"Crockett, Eric","fromEmail":"ericcro@amazon.com","sentAt":"2020-05-29T21:33:41Z","receivedAt":"2020-05-29T21:33:48Z","isPatch":false,"sender":{"key":"ericcro@amazon.com","avatar":null},"body":"My expectation is that `git add -u` will stage precisely the changes listed in `git status` under \"Changes not staged for commit\". However, this isn't the case, and it's confusing. In particular, if I set `ignore=all` in .gitmodules for a submodule and then make changes to that submodule, `git status` does not show the changes (which is what I expect), but `git add -u` still stages the changes to the submodule (not what I expect)! This behavior occurs with git 2.26.2 on Ubuntu 18.04.\n\nThis script demonstrates the problem:\n\n#!/bin/bash -ex\n\necho \"Check out a random repository\"\ngit clone https://github.com/crockeea/cryptonite.git\ncd cryptonite\n\necho \"Add a random submodule\"\ngit submodule add https://github.com/crockeea/wai.git\n\necho \"Track an older commit in the submodule\"\ncd wai\ngit checkout HEAD^\ncd ..\ngit add -A\ngit commit -m \"Added submodule one commit behind its tip-of-master\"\n\necho \"What happens if I check out a newer commit in the submodule?\"\ncd wai\ngit checkout master\ncd ..\ngit status\necho \"git status shows that the submodule is dirty\"\n\necho \"We can fix that by adding `ignore=all` to .gitmodules\"\necho -e '\\tignore = all' >> .gitmodules\n\ngit status\necho \"Now the dirty submodule is not shown\"\n\necho \"This looks good; let's stage the changes to .gitmodules\"\ngit add -u\n\necho \"And verify what was staged...\"\ngit status\necho \"The dirty submodule was staged! This is not what I expect.\"\necho \"I expect that `git add -u` will only stage the changes to .gitmodules\"\n\ncd ..\nrm -rf cryptonite\n\n\nRegards,\nEric Crockett\n"}]}