Skip to content

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

Merged
ndeloof merged 1 commit into
docker:mainfrom
htoyoda18:fix/watch-ignore-nested-git
Oct 20, 2026
Merged

ndeloof merged 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
@ndeloof
ndeloof enabled auto-merge (rebase) October 20, 2026 13:21
@ndeloof
ndeloof merged commit abe5d38 into docker:main Oct 20, 2026
61 of 63 checks passed
@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

2 participants