I have happily been using Git and Git Bash from https://git-scm.com/. There is a page with more information here: https://git-for-windows.github.io/.

Yesterday I ran into a problem with rsync, and I started digging deeper into Git Bash for Windows. I realized that I'm not even sure of the name of the Bash program, because it's just bundled with the git-scm download. I'm calling it Git Bash for Windows, which seems reasonable.

In looking into "What is Git Bash" I read about Cygwin and a different thing called mysys2, which seems to be related to mysysGit, and I saw references to MinGW. But, then I saw in the FAQ that mintty is the the default terminal for Git Bash.

It seems that the Bash application is actually a specially curated bundle of other things (mostly listed above) that are available independently.

Fundamentally, I would like to know what is the basis that makes *nix commands like ssh scp cat ls work in Git Bash for Windows?

(I think a good answer would help someone understand, in broad strokes, how these components fit together and understand the right words for the components, but I don't want to break the SO question / answer format.)

  • Found a very good answer here: What is the exact meaning of Git Bash? – geneorama Sep 12 at 21:17
  • I think the official name / thing to google is "git bash". Helps to have it in quotes since both words are meaningful independently. – geneorama Sep 12 at 21:19
  • Some good discussion on Reddit here and here (from 2017). They even address my original rsync question!! – geneorama Sep 12 at 21:20
up vote 47 down vote accepted

Summary

You are correct, Git Bash for Windows is not just bash compiled for Windows. It's package that contains bash (which is a command-line shell) and a collection of other, separate *nix utilities like ssh, scp, cat, find and others (which you run using the shell), compiled for Windows, and a new command-line interface terminal window called mintty.

In a nutshell

On Windows you might run commands like ipconfig /all or format G: using cmd.exe. These commands are actual executable files under C:\Windows\system32, stored as ipconfig.exe and format.com files. cmd.exe is separate from both and loads and runs them on user's request.

ssh, scp, cat, find are run using bash in exactly the same way. They are usually stored under /usr/bin rather than in C:\Windows\system32 on *nix systems, because Windows and *nix have their system file structure organised differently.

In the case of Git Bash for Windows these programs are located in the Git installation folder: C:\Program Files\Git\usr\bin, which can also be found in the emulated Linux environment under /usr/bin.

Just like being able to just run cmd.exe on *nix doesn't allow you to do much without the other system utilities, just being able to run Bash on Windows is not very useful either. This means that all these extra commands have to be bundled together with Bash to create a usable software package.

Details: POSIX applications on Windows

Normally those extra commands would be found on *nix systems and not on Windows, because they have been programmed against the POSIX programming API (which is what *nix uses), and not the Win32 APIs (which is what Windows uses). POSIX API documentation is openly available, so some people have ported it to other systems, including Windows. Windows implementation of POSIX APIs/libraries are provided by Cygwin and MSYS.

This is kind of similar to what the Wine project does, but it converts POSIX->Windows rather than Windows->POSIX like Wine does.

mintty

mintty is included because cmd.exe, the default Windows command line window, is missing some important features which are normally available on most *nix systems. In most cases, mintty is a better choice for running commands (certainly for the utilities that come with the Git Bash for Windows package), but occasionally a Windows system application may work better with cmd.exe.

  • 1
    Turns out that most of my questions are answered in the project's FAQ: github.com/git-for-windows/git/wiki/FAQ and I can find more specific info in the google group groups.google.com/forum/#!forum/git-for-windows. – geneorama Mar 22 '16 at 14:57
  • @geneorama That shouldn't be a problem to accept this answer if it was indeed correct, informative and useful. – Luis G. Nov 9 '17 at 16:36
  • 1
    @geneorama Filling that blank may have been your intention, but that was not the question you made. Your post is titled "What is Git Bash for Windows anyway?", and the only question present in its body is "I would like to know what is the basis that makes *nix commands like ssh scp cat ls work in Git Bash for Windows?". Pabru's post answers both questions quite nicely and is a correct answer for anybody that may have the same question (as stated), so by accepting it you're helping other users. Have you tried posting a new question for the rsync problem? – Luis G. Nov 15 '17 at 16:39
  • 2
    @walen posting questions on SO and related sites is so unpleasant that I doubt I will ever post more questions.This one was actually a test, and it confirmed my feelings. In my effort to keep the question concise and document my research (and I spent a full day researching), I guess I left out the actual question. When I edit carefully people seem to take the brevity as a lack of research. If I make the question too verbose it gets ignored. No matter what, the question is criticized (several downright rude comments have been deleted). Even my "famous" questions were heavily downvoted at first. – geneorama Nov 22 '17 at 16:12
  • 1
    @geneorama If it's of any consolation to you, your question helped me learn more about git bash, before even reading the answer. But I understand what you mean. – Luis G. Nov 22 '17 at 16:15

Background

I am the OP. I originally wanted just to know the formal name for this thing I was using.

Now I think the name is "git bash for windows". Unfortunately the full answer is complicated because this thing is actually a lot of things.

The top answer from 2016 was originally not helpful for me, but it has been heavily edited and gotten more and more helpful. Still, it misses some of my original question.

The beginning: msysgit

Actually, the beginning is probably msys, but really msys2. The term "msysgit" is a good term to put in a search to figure out what is happening when XYZ goes wrong; things like "where in the @*#! are all the autocrlf settings stored?!?!?!?"

The README (https://github.com/msysgit/msysgit) in the msysgit project explains the relationship between the components:

The relationship between msysGit and Git for Windows

Git for Windows is the software package that installs a minimal environment to run Git on Windows. It comes with a Bash (a Unix-type shell), with a Perl interpreter and with the Git executable and its dependencies.

On the other hand, msysGit is the software package installing the build environment that can build Git for Windows. The easiest way is to install it via the net installer.

The difference between MSys and MinGW

The MinGW project's goal is to provide a way to compile native Windows binaries with no POSIX layer using the GNU C Compiler.

However, at least the Bash needs a POSIX layer (most notably due to the absence of the fork() call on Windows). Therefore, MSys (the minimal system) is thrown in, offering the minimal system necessary to offer Bash (and Perl) functionality on Windows.

Consequently, MSys ships with a POSIX layer (based on an old version of Cygwin) that is only used by the Bash and Perl, but not by anything compiled within that environment.

BTW, just in case the full README gets deleted, I copied it into a gist.

The terminal window: mintty

The other part of git bash for windows is the actual window command line, mintty. Thank goodness it exists, but it's not something I need to google.

References for MSYS2

Their wiki is a real treasure trove of details on the MSYS2 environment: https://github.com/msys2/msys2/wiki

In the introduction, this part is most relevant to my original question:

MSYS2 consists of three subsystems and their corresponding package repositories, msys2, mingw32, and mingw64.

This discussion is very helpful as well: https://sourceforge.net/p/msys2/discussion/general/thread/dcf8f4d3/#8473/588e

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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