Home > other >  Change path for git bash terminal in VSCode
Change path for git bash terminal in VSCode

Time:12-10

When I use a git bash terminal in VSCode, I get the error

'C:\Program' is not recognized as an internal or external command,

operable program or batch file.

That's because the default path for git bash is C:\Program Files... (see pic bellow)

I tried to install a portable Git to the folder without spaces and then in VSCode to change a git path, but it didn't change the path for git bash. Also, I tried to add the "path" parameter in a settings.json, but it looks like the predefined terminals use the default path, not the custom ones defined in the settings.

        "Git Bash": {
            "path": "C:\\Windows\\SysWOW64\\Git\\bin\\Bash.exe"
        }

How can I set the custom path for the git bash terminal?

Terminal path pic

CodePudding user response:

To change the installation path of Git Bash, try renaming "Git Bash" to "Git_Bash". VS Code seems to prefer the default path over any customized path for Git Bash due to a bug. I installed Git under D:\Program Files, so I did this:

{
  "terminal.integrated.defaultProfile.windows": "Git_Bash",
  "terminal.integrated.profiles.windows": {
    "Git_Bash": {
      "path": "D:\\Program Files\\Git\\bin\\bash.exe",
      "icon": "terminal-bash"
    }
  }
}

CodePudding user response:

In my case what helped me was to change git.path in settings.json

  1. Press CTRL SHIFT P

  2. Type Open Settings

  3. Choose Preferences: Open User Settings (JSON)

  4. Change git.path parameter to that

    "git.path": "C:\\PROGRA~1\\Git\\bin\\git.exe",

The explanation found here:

The space in folder name breaks the prompt so in your settings.json file make sure you update the path "Program Files" to simply "PROGRA~1" instead

  • Related