This is a high-level overview of some of the differences between the shells, not a feature by feature comparison.
CMD
(Command Prompt) and PowerShell
are both shells for Windows. CMD.exe
was borne from COMMAND.COM
, which was itself born from MS-DOS
, and has some logical constructs and can run programs, process output, and do most basic tasks you would expect from a shell. It is generally considered very limited based on what other shells can do, but is not incapable if you know how to use it. However, it was never really "designed", with new features getting tacked on without a clear roadmap.
Powershell
is a shell designed from the ground up with ties into .NET and has more modern language constructs built in. Microsoft designed Powershell as a replacement to CMD.exe
and batch scripting, though CMD
is far from being deprecated. Powershell
can call directly into .NET classes, work with WMI objects natively, and has built in remoting capabilities. It is more akin to a programming or scripting language than batch scripting is. There is a much stronger community surrounding Powershell
today than there is for batch scripting, and it is generally recommended to write new code in Powershell
than to continue to use batch (CMD
) scripting.
Powershell
does feel like CMD
at first. You can run programs in it and process their output, and in most cases programs will behave exactly the same whether they are run from Powershell
, or from CMD
. However, you will quickly notice some differences - not all variables are considered environment variables, variables are prefixed with a $
as opposed to being wrapped in %
, and the Powershell
pipeline is far more powerful than the CMD
pipeline. Powershell
is also entirely object-oriented, which is unique when compared to most other shell languages which are primarily text based.
You can read more here about why Powershell
is recommended over batch scripting, and there is a good bit of history on CMD.exe
and batch files as well.
Git Bash
is the same bash
shell you are used to on Linux and MacOS but instead compiled for Windows. It has the Git
prefix with the name to indicate it was installed with Git for Windows, a packaging of git
and various *nix utilities compiled for Windows for use with git. You can run sh
and bash
scripts in it, as well as call the Unix programs it installs with it.
The Unix utilities can generally be run in CMD
or PowerShell
too, but by default the installer does not add these utilities to the SYSTEM or USER PATH
, as to not potentially override the same utilities the user may use in other contexts. Basically, it isolates the utilities installed with Git Bash
to Git Bash
.
Outside of git
automation, I wouldn't recommend using Git Bash
itself for anything production related, you would probably rather manage an installation of cygwin
, msys2
, or another Unix compatibility layer yourself in that case. But it can be a handy shell to have during development, although these days I generally prefer PowerShell
over bash
for Windows scripting.