Home
Support Forums

Git diff --quiet HEAD^ HEAD sub_dir/ does not appear to be working

Greetings, our project is hosted in a monorepo, and while everything appears to be working fine with regards to automatic deployments, I’m having an issue with setting the ignore parameter in my TOML file, and as a result both my sanity dashbord and frontend are getting built and deployed when I only want one or the other to occur when it detects changes in that specific directory.

I have two netlify.toml files in each directory of my project.

root
	#	My Gatsby Project
	-lj-landers-gatsby
		--netlify.toml
	#	My Sanity Project
	-lj-landers-sanity
		--netlify.toml

My Gatsby TOML is:

[build]
  base="lj-landers-gatsby"
  publish="public/"
  command="gatsby build"
  ignore = "git diff --quiet HEAD^ HEAD lj-landers-gatsby/"

My Sanity TOML is:

[build]
  base="lj-landers-sanity"
  publish="dist/"
  command="npm run build"
  ignore = "git diff --quiet HEAD^ HEAD lj-landers-sanity/"

As far as I can tell from reading the docs, this should work, but whenever the build process runs in Netlify, it throws the following error when it gets to the ignore logic.

12:18:09 PM: Detected ignore command in Netlify configuration file. Proceeding with the specified command: 'git diff --quiet HEAD^ HEAD lj-landers-sanity/'

12:18:09 PM: fatal: ambiguous argument 'lj-landers-sanity/': unknown revision or path not in the working tree.

12:18:09 PM: Use '--' to separate paths from revisions, like this:

12:18:09 PM: 'git <command> [<revision>...] -- [<file>...]'

Can someone point me in the right direction as to what we might be doing wrong here?

Hi, @brandonag. This is saying there is no subdirectory lj-landers-sanity/ relative to the base directory of the repo (which is itself lj-landers-sanity if I’m not mistaken).

Does the repo have a subdirectory which named the same as the repo itself?

In other words, let’s say I clone a repo named lj-landers-sanity while in the directory /tmp. The repo itself is going to be found at /tmp/lj-landers-sanity. However, the git diff command above is going to try to check /tmp/lj-landers-sanity/lj-landers-sanity/ and Git will report this error if that directory doesn’t exist.

Does it exist? If not, you should leave that subdirectory out of the command.