Mefitico
Mefitico

Reputation: 1116

git from bash script on Windows using MinGW is not configured

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?

Upvotes: 0

Views: 146

Answers (1)

VonC
VonC

Reputation: 1329112

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.

Upvotes: 1

Related Questions