Windows 下 Git-scm、 msysGit 和 Git 的区别

git-scm(从 Git-scm.com下载)和 msysGit (托管在 谷歌代码Github上,可能还有其他地方)有什么区别?它们看起来非常相似,即使我有 git-scm,我也应用了为 msysGit 指定的修复程序,它们看起来工作得很好。

另外,哪一个(如果有的话)是 Git for Windows,并且都称为 Git Bash,或者两者都有 Git Bash shell,或者只有两者中的一个?

33710 次浏览

The website git-scm.com is the official website for Git, the version control software. There is no “Git-SCM”, that’s just the URL of the source control management (SCM) software—the name is just Git. Originally written for Linux, the original Git software is only available as a source that doesn’t compile easily on Windows.

If you are just interested in installing Git on Windows, then you can stop reading here and just download a Windows build from the official website.

Git for Windows

Git for Windows is the project dedicated to building native builds of Git for Windows. The Windows releases are available for download on the official Git website, they come as 32-bit and 64-bit builds.

Git for Windows is built on top of MSYS2 (a part of MinGW) which provides a minimal unix-like shell environment which is used to run all the components of Git which are not written in native code (a lot of Git is written as shell scripts). In order to build Git with MSYS2, the project group has a special “Git for Windows SDK” which is basically the whole build environment needed to build Git on Windows, and comes with everything you need to start working on Git itself.

The project maintains its own fork of Git which is kept up to date with the original Git project but contains a set of patches necessary to build it on Windows. Git for Windows releases are usually released with a short delay after the official version is released (although versions are sometimes skipped).

msysGit

Prior to Git version 2, the Git for Windows binaries were released by the project called msysGit, which is the predecessor of the Git for Windows project. The project was retired on August 18, 2015 in favor to launch the Git for Windows project with the rebuilt Git for Windows SDK development environment. The new project was mostly started with the same team.

While many people thought of msysGit as the name of the Git binaries, that was actually the name of the development environment they created. It was based on MSYS, the older and kind-of outdated version before MSYS2 was started fresh. The bad state of MSYS was one of the reasons why the Git for Windows project was started with a completely revamped build environment.

The project essentially released three things: msysGit, Git for Windows, and a portable Git for Windows. The msysGit installer would install and set up the development environment required to build Git on Windows, just like the Git for Windows SDK does now. Git for Windows was an installer that would install Git on a Windows machine, and the portable Git for Windows were just the binaries you wouldn’t have to install. Note that all their releases were released as “preview” builds, meaning that they would not be fully supported releases. Despite that, the project was very mature and the releases were very stable and the de-facto best way to set up Git on Windows.

Git Bash

As mentioned above, a lot of Git is written as shell scripts. In order to execute those scripts, Git for Windows uses Bash that comes bundled with MSYS2 (so Bash works as an interpreter for it).

Git Bash commonly refers to the shortcut the Git for Windows installer creates. It launches a full featured console window running Bash, so you can use Git as well as a set of common command line tools or Unix programs (like less, awk, grep, or even the text editor vim). Especially for less experienced users, Git Bash is the common way to interact with Git, although you could easily use it from more Windows-centric environments like PowerShell.

Starting with Git version 2, Git Bash will by default launch in MinTTY, a terminal emulator which comes with MSYS2, making it easily usable even for users not accustomed to a console experience.

It’s also useful to know that Git Bash will always work even if you decided not to add any Git executables to your PATH during the setup of Git for Windows. However, my personal recommendation is to add the Git executable (just the Git executable, choosing the option “Use Git from the Windows Command Prompt” during setup) to the PATH. That way, you can work with Git from other shells (cmd.exe or PowerShell), and other programs can access it too (e.g. many libraries or even IDE integrations expect a Git executable in the PATH to interact with Git repositories).