Home > front end >  git from bash script on Windows using MinGW is not configured
git from bash script on Windows using MinGW is not configured

Time:09-08

I am writing a bash script that needs to perform some git actions. I'm working on windows using MinGW.

running bash test.sh

with test.sh having the content:

echo "git config --global user.name -> $(git config --global user.name)"

This prints:

git config --global user.name ->

Whereas going on powershell and typing git config --global user.name prints my_actual_user_name.

I'd like in this case to user my user settings on git, which would include having access to my ssh keys, which it is not doing. How can I achieve this?

CodePudding user response:

Try to use, both in your script and PowerShell:

git config --show-scope --show-origin user.name

You will see exactly which file is used to query that setting.
If they differ, that would explain your difference in output.


The OP Mefitico confirms in the comments HOME was not set.

Setting a user environment variable HOME to %USERPROFILE% is enough for a git bash session to access the same global .gitconfig setting file as a Git PowerShell session.

  • Related