Custom git command fails (working tree is not clean)

Info

Problem

I have a script which pulls files from another git repo. Part of the process is making a merge commit. It works on my machine, but on Netlify the script fails because of a messy working tree. I’m not sure why a freshly cloned repo would have modifications…

2:16:05 PM: > b3u.netlify.com@1.0.0 postinstall /opt/build/repo
2:16:05 PM: > node scripts/post-install
2:16:05 PM: Command failed: git subtree add --squash --prefix=src/notes/ notes master
2:16:05 PM: Working tree has modifications.  Cannot add.

Possible Solutions

The script works on my machine, with a freshly cloned repo and the netlify-cli build command.
I looked through the documentation, read the blog post about the build process, and even looked through the build image github repo.

I haven’t seen Netlify’s git clone process documented, but I found some lines in the deploy log which may contain a hint. See the last line.

2:15:33 PM: No cached dependencies found. Cloning fresh repo
2:15:33 PM: git clone https://github.com/b3u/b3u.netlify.com
2:15:34 PM: Preparing Git Reference refs/heads/master

Solved it. Not completely sure what the issue was, but I did have to configure the commiter’s email and name.

1 Like