I will try later, but it is not a solution of my problem, because my project must be able to build on different computers with different git installation directories, different OSs and different git versions.
Many tools will do that to isolate the environment from the build process. Even though there can be some frustration in it, as you have discovered in it, there is a lot of good in it.
Accidental pollution from the environment can lead to builds failing on some systems an not others. It can also lead to builds that are not repeatable. Many plugins in Gradle will also isolate the environment to an absolute minimum when running external tools.