21

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.

18 Answers 18

39

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.

4
  • 2
    Thanks changing the name from "Git Bash" -> "GitBash" worked for me ! Nov 23, 2021 at 14:49
  • 1
    @ShrijanRegmi You could also change the name to "Git Bash" -> "Git bash". this one worked. I think its with second word should starts with small letter.
    – Kamar
    Nov 24, 2021 at 5:40
  • For me it worked after removing the space as said in the post above plus adding an empty "args" value.
    – Georg
    May 13, 2022 at 9:15
  • This fix works, but now the terminal is not integrated (i.e., it pops out when I open a new terminal). Any suggestions?
    – adm-gis
    Feb 7 at 20:42
25

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.

9
  • 2
    @LucianAnghel try restarting VS Code after making this change. I noticed that I too would get the same error after doing this, and only after VS Code is restarted does it resolve. That might be a separate bug. So, remove the source, set terminal.integrated.defaultProfile.windows accordingly, save, restart VS Code, and then see if it works.
    – Timothy G.
    Jun 21, 2021 at 15:32
  • 5
    Added path of Git, Git\bin, Git\cmd in env. Removed source and mentioned only the path. Restarted VS Code. No change in behavior. "Git Bash" profile is not recognized.
    – nagu
    Jun 22, 2021 at 5:55
  • 3
    @TimothyG. I changed the profile name in "terminal.integrated.profiles.windows" to "GitBash" instead of "Git Bash". It started showing up in Select Default Profile list. Your comment made me look into this again. Resolved. Thanks :)
    – nagu
    Jun 26, 2021 at 8:12
  • 2
    @TimothyG. Yes, thanks man it worked -> I changed the profile name in "terminal.integrated.profiles.windows" to "GitBash" instead of "Git Bash" Nov 23, 2021 at 14:47
  • 1
    Removing the source worked for me :)
    – OuuGiii
    Jan 4, 2022 at 14:32
9

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"
}
0
6

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"
1
  • One seems to need both steps -- removing source and having a full path. May 24, 2022 at 8:58
5

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"
}
2
  • 1
    did install the git in default location and everything back to normal. Nov 26, 2021 at 11:02
  • is it possible if I have installed Git in a different hd?
    – FJCG
    Jan 19, 2022 at 0:47
2

As of February 2023 (version 1.75.0), the following settings should work.

{
    "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": {
        "path": "${env:homepath}/Software/git/current/bin/bash.exe",
        "icon": "terminal-bash"
      },
    },
    "terminal.integrated.defaultProfile.windows": "GitBash",
}

I downloaded/installed the 64-bit Git binaries to a user directory.

  1. Visit Git - Download for Windows
  2. Locate the Portable ("thumbdrive edition") section
  3. Choose architecture e.g. 64-bit ~ https://github.com/git-for-windows/git/releases/download/v2.39.1.windows.1/PortableGit-2.39.1-64-bit.7z.exe
  4. Install Git to your user directory e.g. "Software/Git"

Notes

  • You do not need to install Git to C:\Program Files\Git
  • You can use forward-slash / instead of an escaped back-slash \\ in paths
  • Spaces are not allowed in the profile name/key. Use either "GitBash" or simply "Bash"
  • If you want to change the "icon" value for your GitBash profile to e.g. Git/GitHub-related icons, you can just use the value "github" or "git-merge". You can use any of VS Code's codicon values as a terminal icon.

See also

1

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
  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!!!

1
{
  "terminal.integrated.profiles.windows":{
    "GitBash":{
      "path":"D:\\projects\\tools\\Git\\bin\\bash.exe"
    },
  },
  "terminal.integrated.defaultProfile.windows": "Git Bash",
  "terminal.integrated.profiles.linux": {

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

0

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", 
0

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"
    }
  }
2
  • 1
    Please add further details to expand on your answer, such as working code or documentation citations.
    – Community Bot
    Sep 4, 2021 at 10:27
  • doesn't work with spaces in the name - see here Jun 14, 2022 at 8:42
0

Remove the brackets in the path worked for me

1
  • 3
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Oct 13, 2021 at 17:37
0
  • 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
0

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.

0

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://'

0

Win11, VS Code 1.71.2

  • maybe you should try this
  • failed (Value is not accepted...)
"terminal.integrated.profiles.windows":{
        "GitBash": {
            "path": "D:\\dev\\Git\\bin\\bash.exe"
        },
        ...
    },
"terminal.integrated.defaultProfile.windows": "GitBash",
  • work
"terminal.integrated.profiles.windows":{
        "GitBash": {
            "path": "D:/dev/Git/bin/bash.exe"
        },
        ...
    },
"terminal.integrated.defaultProfile.windows": "GitBash",
0

I tried the variations of this page. The one that worked for me was:

  "terminal.integrated.profiles.windows": {
    "Git_Bash": {
      "path": "C:/PrgFiles/Git/bin/bash.exe",
      "icon": "terminal-bash"
    },
    // ...
  },
  "terminal.integrated.defaultProfile.windows": "Git Bash",

I removed the source key, which I had along with path.

I had a space in both locations. I had the message:
Value is not accepted. Valid values: null, "PowerShell", "Windows PowerShell", "Command Prompt", "JavaScript Debug Terminal".

If I remove the space in both locations, I have the message:
Value is not accepted. Valid values: null, "PowerShell", "Windows PowerShell", "Git Bash", "Command Prompt", "JavaScript Debug Terminal".

Removing it in the key, and keeping it in the defaultProfile was the solution.
Curiously, it worked previously, but I won't ask questions.

0

Now is 2023 and I had the same problem. I resolved it by restarting VSCode and changing from "GitBash" to "Git Bash". There are a lot of comments that suggest otherwise but for me this is how I solved the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.