24

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.

19 Answers 19

45

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks changing the name from "Git Bash" -> "GitBash" worked for me !
@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.
For me it worked after removing the space as said in the post above plus adding an empty "args" value.
This fix works, but now the terminal is not integrated (i.e., it pops out when I open a new terminal). Any suggestions?
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 Comments

@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.
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.
@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 :)
@TimothyG. Yes, thanks man it worked -> I changed the profile name in "terminal.integrated.profiles.windows" to "GitBash" instead of "Git Bash"
Removing the source worked for me :)
|
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"
}

Comments

7

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 Comment

One seems to need both steps -- removing source and having a full path.
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 Comments

did install the git in default location and everything back to normal.
is it possible if I have installed Git in a different hd?
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

Comments

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

Comments

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

Comments

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:

Comments

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

Comments

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 Comments

Please add further details to expand on your answer, such as working code or documentation citations.
doesn't work with spaces in the name - see here
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

Comments

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.

Comments

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

Comments

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

Comments

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.

Comments

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.

Comments

0

Well, I work with windows. I had my git installed to -> "D:\Git" previously, and I did not see bash terminal show up in the drop-down when I wanted to add a new terminal in VS Code. So, I copied the Git folder to -> "C:\Program Files\Git", and it worked for me.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
-1

Remove the brackets in the path worked for me

1 Comment

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.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.