Git diff return "Error: Process completed with exit code 1."

The following command git diff --no-index --output=restapi-diff.txt latest-restapi.json restapi.json returns exit code 1 without any further details. When using actions checkout.

See here : added generate and deploy restapi-doc action · Fenn-CS/rest-api@949dd32 · GitHub

Actually, there was/is no problem. Figured out, linux diff (similar to gits diff check) and gits git diff returns 1 if there are changes or differences between files and 0 otherwise.

So exit status 1 does not necessarily indicate a fail when using diff (linux) or git diff from git.

The right thing to do is continue-on-fail when using github actions or ignore this status in other build systems.

You could also suppress the exit code by appending || true:

git diff --no-index --output=restapi-diff.txt latest-restapi.json restapi.json || true

1 Like

Yeah! Makes sense. Thanks for the alternative.

1 Like