GitBash not showing up as a terminal option in Visual Studio Code

Viewed 18178

I am trying to insert GitBash as an option in Visual Studio Code. My settings look like so:

"terminal.integrated.profiles.windows": {
    "PowerShell": {
      "source": "PowerShell",
      "icon": "terminal-powershell"
    },
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      "args": [],
      "icon": "terminal-cmd"
    },
    "GitBash": {
      "source": "GitBash",
      "path": ["F:\\Code\\Git\\bin\\bash.exe"],
      "icon": "terminal-bash"
    }
  },
  "terminal.integrated.defaultProfile.windows": "GitBash"

However, at the last line, the error that Visual Studio Code gave is:

Value is not accepted. Valid values: "PowerShell", "Command Prompt".(1)
The default profile used on Windows. This setting will currently be ignored if either #terminal.integrated.shell.windows# or #terminal.integrated.shellArgs.windows# are set.

I do not understand where I went wrong.

Note: "terminal.integrated.shell.windows" is deprecated as of April 2021.

13 Answers

VS Code version 1.57.1.

Added path of Git, Git\bin, Git\cmd in env. Had "Git Bash" profile with source and path elements. Removed source and kept only the path. When adding defaultProfile as "Git Bash" got "Value is not accepted" error. Restarting VS Code did not help.

Changing "Git Bash" to "GitBash" (space removed) finally worked for me:

"terminal.integrated.profiles.windows": {
    "GitBash": {
      "path": ["D:\\ProgramFiles\\Git\\bin\\bash.exe"],
      "args": []
    },
    ...
}
"terminal.integrated.defaultProfile.windows": "GitBash"

I am not sure if space is actually the problem. Because there is a profile "Command Prompt" with space in its name and recognized!!! To confirm this further, changed "PowerShell" to "Power Shell", and it worked too.

I am not clear how space matters only in the "GitBash" profile.

I believe Visual Studio Code uses your PATH variables to find which profiles are available on your machine. I am guessing you do not have the location of Git Bash set in your PATH. But, that should be fine since you specify the path property in the setting. The issue is you are also setting the source property. According to the description for the terminal.integrated.profiles.windows setting, you can either set the source or the path, not both:

The Windows profiles to present when creating a new terminal via the terminal dropdown. Set to null to exclude them, use the source property to use the default detected configuration. Or, set the path and optional args

Delete the source property, and see if the issue resolves and you can open a git bash terminal in Visual Studio Code.

Also, you may need to restart Visual Studio Code after making these changes. It might be a separate bug, but the terminal.integrated.profiles.windows setting won't detect any new profiles added until you restart.

For anybody using a custom dir for git installation: It does not work with Version: 1.60.2 (user setup)

Win10 User:

  1. Install or just copy git in C:\Program Files
  2. Add Path Variables name: GIT_HOME_2 variable: C:\Program Files\Git
  3. In double click on Path and add "%GIT_HOME_2%\bin"
  4. Open VS Code, you should now see the bash terminal
{
    "terminal.integrated.profiles.windows": {
        "PowerShell": {
            "source": "PowerShell",
            "icon": "terminal-powershell"
        },
        "Command Prompt": {
            "path": [
                "${env:windir}\\Sysnative\\cmd.exe",
                "${env:windir}\\System32\\cmd.exe"
            ],
            "args": [],
            "icon": "terminal-cmd"
        },
       
    },
    "terminal.integrated.env.windows": {
    
    },
    "terminal.integrated.defaultProfile.windows": "Git Bash"
}

I have VS Code 1.63.2

Removing the source property or the space in "Git Bash" didn't help. But I found this on their official site and I noticed that the .exe file itself is specified in path:

{
  "terminal.integrated.profiles.windows": {
    "My PowerShell": {
      "path": "pwsh.exe",
      "args": ["-noexit", "-file", "${env:APPDATA}PowerShellmy-init-script.ps1"]
    }
  },
  "terminal.integrated.defaultProfile.windows": "My PowerShell"
}

So I tried adding \\bash.exe to the path in the settings and it worked:

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

This works for me when pasted in the settings.json:

{
  "terminal.integrated.profiles.windows": {
    "GitBash": {
      "path": [
        "C:\\Program Files (x86)\\Git\\bin\\bash.exe"
      ]
    }
  }
}

But only if "GitBash" has no spaces. "Git_Bash" is also fine but not "Git Bash".

Use the syntax below if you want "GitBash" to become the default:

{
  "terminal.integrated.profiles.windows": {
    "GitBash": {
      "path": [
        "C:\\Program Files (x86)\\Git\\bin\\bash.exe"
      ]
    }
  },
  "terminal.integrated.defaultProfile.windows": "GitBash"
}

I had a similar issue. As Timothy. G pointed out, you can only have "source" or "path", not both. But also, simply restarting VS Code enables the newly created profile.
Here's the one I created to have a conda terminal by default (on windows)

"terminal.integrated.profiles.windows": {
  "Conda": {
    "path": "C:\\windows\\System32\\cmd.exe",
    "args": [
      "/K", "C:\\ProgramData\\Anaconda3\\Scripts\\activate.bat C:\\ProgramData\\Anaconda3"
    ],
    "icon": "squirrel"
  }
},
"terminal.integrated.defaultProfile.windows": "Conda", 

This worked for me:

"terminal.integrated.defaultProfile.windows": "Git Bash",
  "terminal.integrated.profiles.windows": {      
    "Git Bash": {
      "path": "C:\\ProgramFiles\\Git\\bin\\bash.exe"
    },
    "PowerShell": {
     
      "icon": "terminal-powershell"
    },
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      "args": [],
      "icon": "terminal-cmd"
    }
  }

Remove the brackets in the path worked for me

  • Open a new terminal by going to Terminal -New Terminal
  • In the right drop downlink -Select Default Profile
  • Then select configure Terminal Profile gear icon
  • Type the name of the profile that need to be created and press Enter
  • Then it will open the setting page and change the path to your terminal path

After struggling with this, a simple solution i found, at least in my case where git is not installed in default path, is to make a symbolic link with this command:

mklink /d "C:\Program Files\Git" "D:\Archivos de Programa\Git"
  • /d stands for symbolic link.
  • First path is where the link be located.
  • Second path is where your Git is actually installed.

After restarting VSCode, i was allowed to see Git Bash on terminal list and set it as default.

The solution is to uninstall git and reinstall it in the default location which is (C:\Program Files\Git). All the other hacks failed.

enter image description here

  1. In VS code go to File -> Preferences -> Settings
  2. Select edit mode in JSON format and set below property value
  "terminal.integrated.profiles.windows": {
    "Bash": {
      "path": "C:\\Git\\bin\\bash.exe"
    },
  }
  1. Reopen the VS code and check the terminal list and select bash

By configuring profile as bash in the above format it worked finally!!!

On Windows - Sept 2022

Open VS Code JSON Settings

  1. Open VS Code
  2. 'Ctrl + ,' Control key combined with comma at the same time
  3. At the top right corner of VS Code, click on the File icon - with a tooltip of Open Settings (JSON)
  4. Now add this code to your JSON file
  "terminal.integrated.defaultProfile.windows": "Git Bash",
  "terminal.external.windowsExec": "C:\\Program Files\\Git\\git-bash.exe",

Note: If you installed Git in a different partition on windows, kindly change the drive to its correct letter and not 'C://'

Related