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?
Bash is an acronym for Bourne Again Shell. A shell is a terminal application used to interface with an operating system through written commands. Bash is a popular default shell on Linux and macOS. Git Bash is a package that installs Bash, some common bash utilities, and Git on a Windows operating system.
So, by installing the Git Bash these utilities will be installed in C:\Program Files\Git\usr\bin folder.
In terms of Git usage, there is no difference. Bash and CMD are the different types of shells. Bash is the one you find in Linux and CMD is the command prompt in Windows. Git keeps it wasy by providing both the bash and cmd versions available.
You don't need to use Git Bash. It is just conventional, because Git was developed and designed on Linux and most Git users use Linux and using Git Bash on Windows makes it a uniform experience. You can certainly use Git on cmd; just make sure you add C:\Program Files\git\cmd to your PATH .
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. You will use these 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
. However, git-bash.exe
does include some environmental setups. For the best way to launch bash.exe
in your preferred terminal, you could get some inspiration from the ConEmu Doc.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With