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

[PATCH v4 0/5] git-add: Skip submodules with ignore=all unless --force and explicit path used

From
Claus Schneider via GitGitGadget <gitgitgadget@gmail.com>
Date
Feb 6, 2026, 13:22 UTC
Message-ID
<pull.1987.v4.git.1770384180.gitgitgadget@gmail.com>
In-Reply-To
<pull.1987.v3.git.1768376879.gitgitgadget@gmail.com>

The ignore=all configuration for submodules is currently honored by status and diff, but not by add. This inconsistency causes friction when working with submodules:

 * Developers unintentionally stage submodule updates, leading to conflicts
   and unnecessary changes.
 * Tracking branches in submodule configs causes friction as updates to the
   submodule SHA1 are added without intent.
This patch aligns git add with the behavior of status and diff:
 * Submodules marked ignore=all are skipped by default.
 * Attempting to add such a submodule explicitly now requires --force.

A submodule can frictionless track a branch in the configuration or manually switched to and use update --update --remote without unintentionally add the changes to the super-project.

Tests that previously added submodules without --force have been updated accordingly. A new test is added to test the behavior of git add with and without --force.

Claus Schneider(Eficode) (5):
  read-cache: update add_files_to_cache take param ignored_too
  read-cache: submodule add need --force given ignore=all configuration
  tests: t2206-add-submodule-ignored: ignore=all and add --force tests
  tests: fix existing tests when add an ignore=all submodule
  Documentation: update add --force option + ignore=all config
 Documentation/config/submodule.adoc |  13 +--
 Documentation/git-add.adoc          |   5 +-
 Documentation/gitmodules.adoc       |   5 +-
 builtin/add.c                       |   2 +-
 builtin/checkout.c                  |   2 +-
 builtin/commit.c                    |   2 +-
 read-cache-ll.h                     |   2 +-
 read-cache.c                        |  80 ++++++++++++++++-
 t/lib-submodule-update.sh           |   6 +-
 t/meson.build                       |   1 +
 t/t2206-add-submodule-ignored.sh    | 134 ++++++++++++++++++++++++++++
 t/t7508-status.sh                   |   2 +-
 12 files changed, 235 insertions(+), 19 deletions(-)
 create mode 100755 t/t2206-add-submodule-ignored.sh
base-commit: 9a2fb147f2c61d0cab52c883e7e26f5b7948e3ed
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1987%2FPraqma%2Frespect-submodule-ignore-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1987/Praqma/respect-submodule-ignore-v4
Pull-Request: https://github.com/gitgitgadget/git/pull/1987
Range-diff vs v3:
 1:  d2b66286c2 = 1:  69e0065b1b read-cache: update add_files_to_cache take param ignored_too
 2:  de72bf0a91 ! 2:  504edcb0f5 read-cache: submodule add need --force given ignore=all configuration
     @@ Commit message
          unless overridden by --force and the submodule path is explicitly specified.
      
          A message is printed (like ignored files) guiding the user to use the
     -    --force flag if the user has explicitely want to update the submodule
     -    reference.
     +    --force flag if the user explicitly wants to update the submodule reference.
      
     -    The reason for the change is support submodule branch tracking or
     -    similar and git status states nothing and git add should not add either
     -    as a default behaviour. The workflow is more logic and similar to regular
     -    ignored files even the submodule is already tracked.
     +    The reason for the change is to support branch tracking in submodules
     +    with configuration `submdule.<name>.branch` or similar workflows where the
     +    user is not interested in tracking each update of the sha1 in the submdule.
     +    You can additionally set `submodule.<name>.ignore=all` and the `git status`
     +    will state nothing and, with this patch, the `git add` does not either - as
     +    the default behaviour. This patch changes the workflow to a more logical
     +    behaviour and similar to workflow for ignored files.
      
     -    The change opens up a lot of possibilities for submodules to be used
     -    more freely and simular to the repo tool. A submodule can be added for many
     -    more reason and loosely coupled dependencies to the super repo which often
     -    gives the friction of handle the explicit commits and updates without
     -    the need for tracking the submodule sha1 by sha1.
     +    The patch gives more scenarios for submodules to be used effectively with
     +    less friction similar to the "repo" tool. A submodule can be added for many
     +    different reasons than a hard dependency. It can be added as loosely
     +    coupled dependencies whereas the user wants the latest based on the
     +    configuration `submoule.<name>.branch`, but are not interested to track
     +    each commit in the `super-repo`. Currently it gives friction of handling
     +    conflicts between branches even the sha1's are fast-forward and the user
     +    just wants the latest in any way. The user can still add a sha1 explicitly
     +    to track updates.
      
          Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>
      
 3:  d7b97e12d3 = 3:  d5ea8eb6e0 tests: t2206-add-submodule-ignored: ignore=all and add --force tests
 4:  6e44ab6804 = 4:  df5c85d9f2 tests: fix existing tests when add an ignore=all submodule
 5:  37fe7956e0 ! 5:  8bfaa14d44 Documentation: update add --force option + ignore=all config
     @@ Documentation/config/submodule.adoc: submodule.<name>.fetchRecurseSubmodules::
      -	commit when it has been staged), "dirty" will ignore all changes
      -	to the submodule's work tree and
      +	a submodule as modified.
     -+	Set to "all" will never consider the submodule modified. It can
     ++	When set to "all" will never consider the submodule modified. It can
      +	nevertheless be staged using the option --force and it will then show up
      +	in the output of status.
     -+	Set to "dirty" will ignore all changes to the submodule's work tree and
     ++	When set to "dirty" will ignore all changes to the submodule's work tree and
       	takes only differences between the HEAD of the submodule and the commit
       	recorded in the superproject into account. "untracked" will additionally
       	let submodules with modified tracked files in their work tree show up.
      -	Using "none" (the default when this option is not set) also shows
      -	submodules that have untracked files in their work tree as changed.
     -+	Set to "none"(default) It is also shows submodules that have untracked
     -+	files in their work tree as changed.
     ++	When set to "none"(default) It also show submodules as changed if they have
     ++	untracked files in their work tree.
       	This setting overrides any setting made in .gitmodules for this submodule,
       	both settings can be overridden on the command line by using the
       	"--ignore-submodules" option. The 'git submodule' commands are not
-- 
gitgitgadget
Previous: Claus SchneiderNext: Claus Schneider(Eficode) via GitGitGadget
Message 29 of 43 in “git-add : Respect submodule ignore=all and only add changes with --force”
  1. 0/5 git-add : Respect submodule ignore=all and only add changes with --forceClaus Schneider via GitGitGadget, Oct 18, 2025
  2. 1/5 read-cache: update add_files_to_cache to take param ignored_too(--force)Claus Schneider(Eficode) via GitGitGadget, Oct 18, 2025
  3. 2/5 read-cache: let read-cache respect submodule ignore=all and --forceClaus Schneider(Eficode) via GitGitGadget, Oct 18, 2025
  4. 3/5 tests: add new t2206-add-submodule-ignored.sh to test ignore=all scenarioClaus Schneider(Eficode) via GitGitGadget, Oct 18, 2025
  5. 4/5 tests: fix existing tests when add an ignore=all submoduleClaus Schneider(Eficode) via GitGitGadget, Oct 18, 2025
  6. 5/5 Documentation: update add --force and submodule ignore=all configClaus Schneider(Eficode) via GitGitGadget, Oct 18, 2025
  7. Phillip WoodOct 19, 2025
  8. 0/5 git-add : Respect submodule ignore=all and only add changes with --forceClaus Schneider via GitGitGadget, Nov 13, 2025
  9. 1/5 read-cache: update add_files_to_cache take param include_ignored_submodulesClaus Schneider(Eficode) via GitGitGadget, Nov 13, 2025
  10. Junio C HamanoNov 13, 2025
  11. 2/5 read-cache: add/read-cache respect submodule ignore=allClaus Schneider(Eficode) via GitGitGadget, Nov 13, 2025
  12. 3/5 tests: add new t2206-add-submodule-ignored.sh to test ignore=all scenarioClaus Schneider(Eficode) via GitGitGadget, Nov 13, 2025
  13. 4/5 tests: fix existing tests when add an ignore=all submoduleClaus Schneider(Eficode) via GitGitGadget, Nov 13, 2025
  14. 5/5 Documentation: add --include_ignored_submodules + ignore=all configClaus Schneider(Eficode) via GitGitGadget, Nov 13, 2025
  15. Junio C HamanoNov 13, 2025
  16. Claus SchneiderNov 14, 2025
  17. Claus SchneiderFeb 5, 2026
  18. Junio C HamanoFeb 5, 2026
  19. 0/5 git-add: Skip submodules with ignore=all unless --force and explicit path usedClaus Schneider via GitGitGadget, Jan 14, 2026
  20. 1/5 read-cache: update add_files_to_cache take param ignored_tooClaus Schneider(Eficode) via GitGitGadget, Jan 14, 2026
  21. 2/5 read-cache: submodule add need --force given ignore=all configurationClaus Schneider(Eficode) via GitGitGadget, Jan 14, 2026
  22. Kristoffer HaugsbakkJan 15, 2026
  23. Claus SchneiderJan 16, 2026
  24. 3/5 tests: t2206-add-submodule-ignored: ignore=all and add --force testsClaus Schneider(Eficode) via GitGitGadget, Jan 14, 2026
  25. 4/5 tests: fix existing tests when add an ignore=all submoduleClaus Schneider(Eficode) via GitGitGadget, Jan 14, 2026
  26. 5/5 Documentation: update add --force option + ignore=all configClaus Schneider(Eficode) via GitGitGadget, Jan 14, 2026
  27. Ben KnobleJan 14, 2026
  28. Claus SchneiderJan 16, 2026
  29. 0/5 git-add: Skip submodules with ignore=all unless --force and explicit path usedClaus Schneider via GitGitGadget, Feb 6, 2026
  30. 1/5 read-cache: update add_files_to_cache take param ignored_tooClaus Schneider(Eficode) via GitGitGadget, Feb 6, 2026
  31. Junio C HamanoFeb 9, 2026
  32. Junio C HamanoFeb 9, 2026
  33. 2/5 read-cache: submodule add need --force given ignore=all configurationClaus Schneider(Eficode) via GitGitGadget, Feb 6, 2026
  34. 3/5 tests: t2206-add-submodule-ignored: ignore=all and add --force testsClaus Schneider(Eficode) via GitGitGadget, Feb 6, 2026
  35. 4/5 tests: fix existing tests when add an ignore=all submoduleClaus Schneider(Eficode) via GitGitGadget, Feb 6, 2026
  36. 5/5 Documentation: update add --force option + ignore=all configClaus Schneider(Eficode) via GitGitGadget, Feb 6, 2026
  37. Kristoffer HaugsbakkMar 4, 2026
  38. Claus SchneiderMar 10, 2026
  39. Claus SchneiderMar 10, 2026
  40. Junio C HamanoFeb 20, 2026
  41. Claus SchneiderOct 20, 2025
  42. Phillip WoodOct 24, 2025
  43. Claus SchneiderNov 13, 2025

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.