Netlify ignore command and git cache


I have trouble understanding on which version of the git repository the Netlify builder is starting.
I made this ignore command because we use a monorepo: ! git diff main --name-only | grep ^docs/, this is similar to git diff --quiet main docs but actually should output the list of files that were detected.

Now it’s been a few days since I had PRs modifying the content of the docs folder and the following PRs (completely unrelated to docs folder changes) were starting to not be ignored by the Netlify build. Let me give an example here Helm chart: bump to v1.0.3 by mtardy · Pull Request #856 · cilium/tetragon · GitHub, you can see here Netlify App that it detected a change in docs/ that was modified by a previous PR while the PR #856 was completely built from the latest origin HEAD, already containing that change (like if we rebased on main recently). I tried “Clear cache and retry with latest branch commit” and it’s even more puzzling, no output, and the workflow just builds Netlify App.

So I think there is something related to the caching of the git repo or my Netlify ignore command that I don’t understand. Because locally it should return zero from my copy of the repository that is up to date, but clearly it does not on the Netlify builder side.



Did you try clearing the build cache and see if that resolves the issue. You can also try running a clean build by removing any previously built files before triggering a new build.

Yep yep I tried to empty the cache and everything but honestly, I could not really understand the state in which the Git repository is on the Netlify runner side.

I ended up using the default suggested command:

  ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ."

And it just worked as expected.

Oh that’s awesome! glad to hear you got this sorted. (: