Launching Git Bash in Mintty, ConEmu, VS Code, IntelliJ IDEA, and More
Updated 2021-June-1

Page contents

News

2021-August-17  Git For Windows v2.33.0 released. To keep up with releases of Git For Windows, which includes the Mintty terminal emulator and Git Bash, see github.com/git-for-windows/git/releases or twitter.com/@GitForWindows.

2021-March-22  Published this evolving⁠[1] article.

About Git Bash

Git Bash is a Windows command-line shell that is packaged with Git For Windows. It emulates⁠[2] the bash shell that is familiar to nix-nux users. To learn about Git Bash, see Infinite Ink’s Git Bash Is My Preferred Windows Shell and #git-⁠bash Portal.

💡
Git Bash is useful even if you do not use git.

 

About terminal emulators

To interact⁠[3] with Git Bash and command-line shells in general, humans use a terminal emulator. Terminal emulators are also known as terminals and consoles.

 

Launch Git Bash in Git Bash’s default terminal emulator (Mintty)

If you install Git Bash with the default Git For Windows set-up options, you will easily be able to launch Git Bash in the Mintty terminal emulator from Windows File Explorer or from a Windows Desktop shortcut.

 

Via File Explorer

In Windows File Explorer, right-click any folder and choose Git Bash Here in the pop-up context menu. This launches Git Bash in Mintty with the right-clicked folder as the working directory.

 

Via a desktop shortcut

If you double click the Git Bash shortcut on your Windows Desktop, it will launch Git Bash in Mintty with your home directory (~) as the working directory.

If you right-click on the default Desktop Git Bash shortcut and choose Properties, you will see something like the following.

Target: "C:\Program Files\Git\git-bash.exe" --cd-to-home

Start in: %HOMEDRIVE%%HOMEPATH%

You can change these shortcut properties if you like. For example, to start in the C:\ directory, use this:

Target: "C:\Program Files\Git\git-bash.exe" --cd=C:\

To start in a directory specified by an environment variable, use something like this:

Target: "C:\Program Files\Git\git-bash.exe" --cd=%INFINITEINKROOT%

Some of git-bash.exe's command-line options, such as --cd, are discussed in superuser.com/questions/1104567/how-can-i-find-out-the-command-line-options-for-git-bash-exe.

 

git-bash.exe runs mintty.exe. To launch Git Bash in a non-Mintty terminal, use git-⁠cmd.exe, examples of which are in the next two sections.

 

Launch Git Bash in the ConEmu terminal emulator

The easiest way to set up ConEmu to launch Git Bash is to do the following in this order:

  1. Install Git For Windows, which includes Git Bash.

  2. Install ConEmu.

If you install these apps in this order, the following will automatically be one of the options in ConEmu’s Choose your startup task: list.

{Bash::Git bash}

Then all you have to do is choose this option and it will just work.⁠👏

If you need to manually add a ConEmu startup task for Git Bash, follow the instructions at conemu.github.io/en/GitForWindows.html. In March 2021, this command is recommended:

git-cmd.exe --no-cd --command=usr/bin/bash.exe -l -i
^^^^^^^                       ^^^^^^^
 Note                          Note

 

Launch Git Bash in Visual Studio Code’s integrated terminal emulator

To use Git Bash in VS Code's integrated terminal emulator, do the following two steps.

  1. Follow the Git Bash instructions at code.visualstudio.com/docs/editor/integrated-terminal. In March 2021, the VS Code documentation suggested including this⁠[4] in your settings.json:

    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\git-cmd.exe",
    "terminal.integrated.shellArgs.windows": [
      "--command=usr/bin/bash.exe",
      "-l",
      "-i"
    ]

  2. If the Backspace key does not work, set your Git Bash TERM environment variable to cygwin or xterm. How to do this is discussed in Infinite Ink’s Git Bash Is My Preferred Windows Shell in the ~/.bash_profile section.

 

Launch Git Bash in IntelliJ IDEA’s integrated terminal emulator

To learn about IntelliJ IDEA's integrated terminal emulator, see www.jetbrains.com/help/idea/settings-tools-terminal.html. On that page, there are seven “Shell path” examples, but unfortunately Git Bash is not one of the examples. The following is suggested for Cygwin:

"C:\cygwin\bin\bash.exe" --login -i

Since Git Bash is similar to Cygwin, I tried this:

"C:\Program Files\Git\usr\bin\bash.exe" --login -i

And it worked!⁠[4]

 

Launch Git Bash in Windows Terminal terminal emulator

To use Git Bash with Microsoft’s Windows Terminal, which is also known as wt.exe, follow the instructions at github.com/microsoft/terminal/blob/main/doc/user-docs/ThirdPartyToolProfiles.md. In April 2021, this⁠[4] JSON fragment is suggested:

{
  "name": "Git Bash",
  "commandline": "C:\\Program Files\\Git\\bin\\bash.exe -li",
  "icon": "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico",
  "startingDirectory": "%USERPROFILE%"
}

 

You may want to change the highlighted line above to this:

"commandline": "C:\\Program Files\\Git\\usr\\bin\\bash.exe -li",
                                        ^^^^^
                                        Note

This may be better because…

On the other hand, it may or may not be better because of reasons discussed in…

 

For more about this, see Microsoft’s Windows Terminal General Profile Settings. If you have thoughts about what is the best way to launch Git Bash in Windows Terminal, please comment below.⁠

 

See also

Endnotes


1. Many Infinite Ink articles, including this one, are evergreen and regularly updated.
2. Git Bash uses MSYS2 (Minimal SYStem 2) and MinGW (Minimalist GNU for Windows) to do this emulation.
3. When you launch bash.exe with the -i command-line option, it means you want to be able to interact with the Bash shell.
4. Assuming Git For Windows is installed in Git Bash’s default install directory (C:\Program Files\Git\).

Comments 👍 👎 📝

Please comment so I know I'm not speaking into the void. Also, your public comment might improve this page or help me to improve this page.