gitvisual-studio-code

VS Code not recognizing that I have user name and email set for git


Having an issue that I have not been able to figure out.

I have git-bash installed from git-scm.com on Windows 10.

I have configured the user name and email globally. Using the command:

git config --global --add user.name me
git config --global --add user.email me@work.com

With a git bash window launched from the shortcut, I have no issue committing and pushing changes. the commits properly have the name and email.

From the git terminal window in VS Code, the same. works fine.

But if I use the Source Control view and try to commit changes in a repo, VS Code pops up a dialog telling me I need to configure my user name and email.

At this point, I assume it's looking in a different place than what is going on at terminal (either in VS Code or stand alone).

Does anyone have a clue where VS Code Source Control gets its config info to operate git in that environment? This may be related to the setting of HOME in the environment but not sure.

the result of running the asked for command is:

$ git config --show-origin --show-scope --get-all user.name
global  file:C:/Users/me/.gitconfig   me

Solution

  • I eventually figured out mostly what was going on. I tried using the git commands in the default powershell window and they also showed that the values were not set. I set them using the commands there (vs doing it from my git bash shell). Those values were taken and used by VS Code. checking the file system showed it created a config file in a directory that was slightly different from the one git bash was using for config files.

    [more details] In our environment we have HOMEDRIVE and HOMEDIR set to root path on a shared drive (windows). This share became R/O due to config changes I don't control. I also have no control of the setting of HOMEDRIVE and HOMEDIR environment vars. I defined HOME to point to my local user directory with the form /c/Users/username to give git bash a R/W location to manage config. That was fine for git bash but but VSCode took it as path on c: drive. Once I set the git config global settings from with powershell terminal in VS Code it set up a git config file in c:\c\Users\username and the VS Code git gui was able to function correctly