microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.16k stars 29.28k forks source link

VSCode ignores .gitconfig file #208329

Open scottmwyant opened 7 months ago

scottmwyant commented 7 months ago

Does this issue occur when all extensions are disabled?: Yes

Steps to Reproduce:

  1. git config --system --edit
[core]
    editor = notepad
  1. git init
  2. git commit --allow-empty
  3. Notepad should open, enter a commit message.
  4. code .
  5. Create file.txt in the root of the repository, content can be anything, "Hello World".
  6. Use VSCode GUI to stage the file, click Commit without providing a commit message.

Expected Notepad should open for you to provide a commit message.

Actual A new editor opens in VSCode.

Something in the application is overriding the setting in my system level .gitconfig file.

Additional Info

My team has been struggling with this for quite some time. I've used the core.editor key as an example, I've seen other settings get "ignored" for lack of a better word.

Specifically, user.name and user.email. These appear in the global config file, verified by git config --show-origin user.name user.email, but VSCode complains and says that a commit can't be made without a user and email provided. When this happens, we've always been able to make a commit using a separate terminal, but not in VSCode.

The fix has been to uncheck this setting Git: Require Git User Config.

scottmwyant commented 7 months ago

I was able to replicate this in Windows Sandbox, installing:

lhasadad commented 6 months ago

I had similar issue. I eventually solved it by using git config within the terminal window to set the configuration. Doing that created the config file at a different path but it was recognized by VS Code. This seems to be related to how VS Code finds the file with certain environment variables set (at least for me).

Arko109 commented 4 months ago

Similar issue here, on my work machine the home drive is set to a network location, and the global git config is in there, but VS Code doesn't seem to see it. However, if I do git config --list --show-origin in the terminal, it shows the values from the network drive.

scottmwyant commented 4 months ago

I think @Arko109 is onto something. I have the same home drive setup on my work laptop and come to think of it, pretty sure that's the only place I've seen this.

@lhasadad can you share where (absolute path) the config file is created when you used VS Code terminal?

I kind of suspected this but as the comment above says, using --show-origin seems to show the config file from the network drive only. So I haven't been able to figure out where the other config is in the filesystem.

nagilson commented 2 months ago

Do you happen to have the .NET Install Tool installed?

scottmwyant commented 2 months ago

Do you happen to have the .NET Install Tool installed?

Maybe... can you edit to provide a link or docs or something. Not recalling exactly what it is you're asking about. I do have full VS and MS Build Tools installed, separately from VS.

nagilson commented 2 months ago

It's this extension. image

I'm guessing not because your repro doesn't have it. But we just saw an issue where we rely on Azure get-proxy-settings and this sets the HOME variable, which is causing a similar behavior.