DEV Community

How to set Git Bash as integrated terminal in VSCode in 2021

Andrew on May 13, 2021

"terminal.integrated.profiles.windows": { "PowerShell": { "source": "PowerShell", "icon": "terminal-powershell" }, "Command Prompt": { ...
Collapse
 
rileyseaburg profile image
Riley Seaburg •

Check the bracets make sure they are properly aligned.

    "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": "Git Bash",
          "path": ["C:\\Program Files\\Git\\bin\\bash.exe"],
          "icon": "terminal-bash"
        }
    },
    "terminal.integrated.defaultProfile.windows": "GitBash",
Enter fullscreen mode Exit fullscreen mode
Collapse
 
brandiqa profile image
Michael Wanyoike •

One more thing, before closing the editor. Make sure to hit the Delete icon to close the Powershell tab. Otherwise when you re-open the project, it won't respect the default profile you had set but instead open Powershell again.

Collapse
 
melvh profile image
MelVH •

Hi,
In case you have not been able to resolve your default shell in vs code, i updated mine today using the following:
"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"
},
"Git Bash": {
"source": "Git Bash"
}
},
"terminal.integrated.defaultProfile.windows": "Git Bash",

This worked for me. My default shell is now Git Bash.

Further note:
Originally, there were settings in my JSHint extention configurations as follows:
"terminal.integrated.shell.windows": "C:\Program Files\Git\bin\bash.exe",
"terminal.integrated.shellArgs.windows": [
"--login"
],

I removed this piece of original settings first.

Collapse
 
bighjs profile image
bigHjs • • Edited

The same question , I just replace Git Bash =》 GitBash

Collapse
 
guest951 profile image
guest951 •

it does not seem to work to have path and source property at the same time (see there:
stackoverflow.com/questions/680683...). i had to remove the source property to make that working. i also confirm that it doesn't work with space between git and bash.

Collapse
 
jemengullo profile image
Jerome • • Edited

This worked for me.

  1. Reinstalled Git Bash to primary drive (C:).
  2. Checked "Add a Git Bash Profile to Windows Terminal".
  3. Restarted VS Code and I can already pick Git Bash as the opened terminal.
Collapse
 
ruvindarkr profile image
Ruvinda Ranaweera •

This worked for me. Had it installed on a different drive before and nothing worked.
Installed on drive (C:) and worked. Thanks.

Collapse
 
kadiryumlu profile image
Kadir Yumlu •

It doesnot work for me. I still have powershell as default shell.

Collapse
 
projektorius96 profile image
LG •

@kadiryumlu try this:
{
"terminal.external.windowsExec": "",
"terminal.explorerKind": "external",
"terminal.integrated.cwd": "C:\Users\%USERNAME%",
"php.validate.executablePath": "C:\xampp\php\php.exe",
"browser-preview.startUrl": "localhost/",
"phpserver.phpPath": "C:\xampp\php\php.exe",
"workbench.editor.untitled.hint": "hidden",
"workbench.colorTheme": "Visual Studio Light",
"terminal.integrated.tabs.enabled": true,
"[json]": {

    "editor.quickSuggestions": {
        "strings": true
    },
    "editor.suggest.insertMode": "replace"
},
"terminal.integrated.defaultProfile.windows": "Git Bash",
"terminal.integrated.profiles.windows": {
    "PowerShell": null,
    "Command Prompt": {
        "path": [
            "${env:windir}\Sysnative\cmd.exe",
            "${env:windir}\System32\cmd.exe"
        ],
        "args": [],
        "icon": "terminal-cmd"
    },
    "Git Bash": {
        "source": "Git Bash"
    },
    "profile": {
        "path": "C:\Program Files\Git\bin\bash.exe",
        "args": [
            "--login"
        ]
    }
},
Enter fullscreen mode Exit fullscreen mode

}

Collapse
 
andrewriveradev profile image
Andrew •

I updated the article should work now!

Collapse
 
colour_shines profile image
Carlos Sánchez •

I've found this Video Posted One month ago(08/09/2021)

works fine for me

youtube.com/watch?v=Yn-ANAtDQ_0

Collapse
 
sebi1moi profile image
Sebi1moi •

Hello,
I'm on Windows 11.
I try and works for me if I call the terminal "GitBash" or anyhow but not "Git Bash" with a space. Do you know why ?
Also, the attribute "source" doesn't want to works to : I must use a "path" attribute. Have you any idea why too ?
Thank's very much !!
Seb

Collapse
 
brandiqa profile image
Michael Wanyoike •

The new VS Code update has a bad UI design in the terminal. There's a second drop down after the + symbol where one can switch the terminal type and select the default type

Collapse
 
andrewriveradev profile image
Andrew •

I updated the article. Now you Git Bash is the default terminal to load when you open the terminal!

Collapse
 
brettshenk profile image
brett-shenk •

Thanks for the tip!

Collapse
 
nkkfu profile image
Nelson Kenmochi •

Thanks! :)

Collapse
 
ralainirina_tiavinamicha profile image
Ralainirina Tiavina Michael •

Thanks. You should specify it for windows user only.
Have you try it with MacOs?

Collapse
 
ipapoutsidis profile image
Ilias Papoutsidis •

Hey @andrew , it works fine for me.
Thanks