13

In the install path of git for windows, I found these 3 exes:

./git-bash.exe,

./bin/bash.exe,

./bin/sh.exe,

Launching any of them would give me a usable terminal.

The 1st is the default shortcut in the start menu created by the installation, the 2nd is used in the VSCode doc for setting up the integrated terminal in VSCode, the 3rd is mentioned in the ConEmu doc.

What's the difference between them and which should I use?

1
  • The first would be the terminal emulator and bash and sh are shells.
    – fredrik
    Commented Dec 30, 2018 at 20:58

3 Answers 3

6

To answer the question, you need to first understand "shell" vs "terminal app".

A "shell" is an interpreter of your commands. When you type same commands in cmd and bash you get different results, because they're different interpreters. Examples of shells include cmd, powershell, sh, bash, zsh, etc (both bash and zsh are more powerful versions of sh). On windows, these shells exist as .exe files. Double clicking them will launch a CLI window. The window is a bare minimum "terminal app" provided by Windows, the window doesn't have an official name.

A "terminal app" is a GUI that emulates physical terminals of the old days, they offer UI features like tabs, fonts, colors, etc. Examples of terminal apps include Git Bash, ConEmu, the terminal in VSCode, the new Window Terminal, etc. You can open any shell inside them.

Back to the original question: sh.exe and bash.exe are shells. Bash is a superset of sh, with more features. You'll likely use bash if you have your own preferred terminal app. git-bash.exe is a terminal app (a very basic one, its name is "mintty") which will automatically open the bash shell. If you have your own preferred terminal app (like ConEmu or the new Windows Terminal), then you don't need to use git-bash.exe.

1
  • What is \bin\bash? is it made by git or just regular MinGW?
    – Tuor
    Commented May 19, 2022 at 13:37
2

git-bashis part of "Git for windows" and provides a command line environment similar to *nix bash.

Windows 10 includes "Windows subsystem" which could provide a Linux environment inside Windows (which includes sh and bash, a short comparison can be found at Difference between sh and bash)

You can use any of them for git. It may be an advantage to use the same as your co-workers (if you would need any help with the shell or a script).

1
  • Thanks for linking the Difference between sh and bash, which was useful. However, the question did not ask anything about WSL.
    – ZYinMD
    Commented Dec 31, 2018 at 2:28
1

The Bourne-Again Shell orbash is a super-set of sh i.e. whatever you can do in sh can also be done in bash. Bash has more features making it easier to write scripts.

On the other hand, Git bash is a msys shell included in Git for Windows since Windows natively does not support bash features (unless you add the Windows Sub-sytem for Linux).

Your Answer

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

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