Skip to content

fix(watch): ignore .git at any depth inside the watched path - #14363

Open
htoyoda18 wants to merge 1 commit into
docker:mainfrom
htoyoda18:fix/watch-ignore-nested-git
Open

htoyoda18 wants to merge 1 commit into
docker:mainfrom
htoyoda18:fix/watch-ignore-nested-git

Conversation

@htoyoda18

@htoyoda18 htoyoda18 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

Makes docker compose watch ignore changes under the project's .git directory, as it was meant to. Before this change, git operations inside the watched path were synced into containers, and with a rebuild action a single edit triggered rebuilds that never stopped.

Related issue

Fixes #14362

Changes made

  • pkg/compose/watch.go: the hardcoded .git ignore rule in getWatchRules now uses the **/.git pattern instead of .git/. Patterns are joined to the / base path, so .git/ only matched /.git, while watch events carry full paths such as /home/me/project/.git/index. The rebuild loop came from buildx updating .git on every build while it reads the git state for provenance, so each build looked like a new change.
  • pkg/compose/watch_test.go: a table test checking that the watch rule ignores .git, its content, and a nested .git (vendor/lib/.git/HEAD), but not main.go, .gitignore or .github/. The .git cases fail without the fix.
  • The initial sync has the same pattern but is left unchanged: it matches on base names, so it already skips .git directories.

Testing done

  • Unit tests pass: make test
  • E2E tests pass: make e2e-compose or make e2e-compose-standalone
  • Linting passes: make lint
  • Code formatted: make fmt
  • Manually tested (describe):

AI tool used (if applicable)

AI Tool:

Additional context

#14217 also changes the ignore rules in pkg/compose/watch.go (it excludes the Dockerfile and compose files) but does not touch .git. Whichever lands second may need a small rebase.

(not mandatory) A picture of a cute animal, if possible in relation to what you did

image

Signed-off-by: hiroto.toyoda <hiroto.toyoda@dena.com>
@htoyoda18
htoyoda18 marked this pull request as ready for review October 19, 2026 14:45
@htoyoda18
htoyoda18 requested review from a team as code owners October 19, 2026 14:45
@htoyoda18
htoyoda18 requested review from glours and ndeloof October 19, 2026 14:45

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] watch rebuilds in an endless loop when the watched path contains .git

1 participant