DEV Community

Andrew
Andrew

Posted on Edited on

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

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

Enter fullscreen mode Exit fullscreen mode

As of April 2021 "terminal.integrated.shell.windows" is deprecated in VSCode.

"terminal.integrated.shell.windows": "C:\\...\\...\\bin\\bash.exe",
Enter fullscreen mode Exit fullscreen mode

To configure Git Bash as the default integrated terminal in VSCode version 1.56 on Windows 10

Step 1: Open command palette (CMD + Shift + P)
Step 2: Search "Preferences: Open User Settings (JSON)"
Step 3: Create a new field by typing "" (double quotation key). Inside the quotation type "terminal." a list of options will appear.
Step 4: Select terminal.integrated.profiles.windows. When you select terminal.integrated.profiles.windows it will be expanded to:

"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"
  }
},
Enter fullscreen mode Exit fullscreen mode

Step 5: Set default terminal to Git Bash

  "terminal.integrated.defaultProfile.windows": "GitBash",
Enter fullscreen mode Exit fullscreen mode

IMPORTANT
The defaultProfile.windows value must be one word to work.

  "terminal.integrated.profiles.windows": {
    "PowerShell": {
    "source": "PowerShell",
    "icon": "terminal-powershell"
  },
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      "icon": "terminal-cmd"
    },
    "Git Bash": {
      "path": ["C:\\Program Files\\Git\\bin\\bash.exe"],
      "source": "Git Bash",
      "icon": "terminal-bash"
    },
  }, 
  "terminal.integrated.defaultProfile.windows": "Git Bash",
Enter fullscreen mode Exit fullscreen mode

Does not work!

// End

Documentation:

Related

Top comments (18)

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!