Cmd.execute().text loses user context while executing a git command?

Trying to run a “git commit -a” command from a gradle task that does
[‘git’, ‘commit’, ‘-a’, ‘-m’, ‘…’].execute().text.trim()

but it logs this into stderr:
*** Please tell me who you are.
fatal: unable to auto-detect email address

It does a bunch of stuff to make edits to a file and then tries to commit the changes so I haven’t used the task:Exec commandLine technique (though I’m not sure what the difference is between that and doing a .execute() directly?)
Also tried running this w/ “–no-daemon” in case it was running in the context of the daemon.

Is there any way to keep the context of the user running the gradle command line like a bash script would?

I could probably use one of the git gradle plugins, but I’d like to understand why gradle is not working this way first…

FYI, switching over to using grgit worked fine…still would like to know why doing .execute() loses user context though…