Windows 版 Git-scm、msysGit 和 Git 之间的差异

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22310007/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 11:26:53  来源:igfitidea点击:

Differences between Git-scm, msysGit & Git for Windows

windowsgitmsysgitgit-bash

提问by trysis

What is the difference between git-scm(downloaded from git-scm.com) and msysGit (hosted on Google Code, Github, and probably others)? They both seem pretty similar, and even though I have git-scm, I have applied fixes specified for msysGit and they seem to work fine.

git-scm(从git-scm.com下载)和 msysGit(托管在Google CodeGithub和其他平台上)有什么区别?它们看起来非常相似,即使我有 git-scm,我也应用了为 msysGit 指定的修复程序,它们似乎工作正常。

Also, which one, if either, is Git for Windows, and are both called Git Bash, or do both have the Git Bashshell, or only one of the two?

另外,哪一个(如果有)是Git for Windows,并且都被称为Git Bash,或者两者都有Git Bash外壳,或者只有两者之一?

回答by poke

The website git-scm.comis 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.

网站git-scm.com是版本控制软件 Git 的官方网站。没有“Git-SCM”,它只是源代码控制管理 (SCM)软件的URL——名称只是Git。最初为 Linux 编写的原始 Git 软件仅可作为在 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.

如果您只是对在 Windows 上安装 Git 感兴趣,那么您可以停止阅读此处,只需从官方网站下载 Windows 版本即可。

Git for Windows

适用于 Windows 的 Git

Git for Windowsis 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是专门用于构建适用于 Windows 的 Git 的本机版本的项目。Windows 版本可在官方 Git 网站上下载,它们有 32 位和 64 位版本。

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 everythingyou need to start working on Git itself.

Windows 版 Git 建立在 MSYS2(MinGW的一部分)之上,它提供了一个最小的类 Unix shell 环境,用于运行所有不是用本机代码编写的 Git 组件(很多 Git 被编写为 shell脚本)。为了使用 MSYS2 构建 Git,项目组有一个特殊的“Git for Windows SDK”,它基本上是在 Windows 上构建 Git 所需的整个构建环境,并且附带您开始使用 Git 本身所需的一切

The project maintains its own fork of Gitwhich 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 releasesare usually released with a short delay after the official version is released (although versions are sometimes skipped).

该项目维护自己的 Git 分支,分支与原始 Git 项目保持同步,但包含一组在 Windows 上构建它所需的补丁。Git for Windows版本通常在正式版本发布后会有短暂的延迟发布(尽管有时会跳过版本)。

msysGit

管理系统

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

在 Git 版本 2 之前,Git for Windows二进制文件由名为msysGit的项目发布,该项目是Git for Windows项目的前身。该项目于 2015 年 8 月 18 日退役,转而使用重建的Git for Windows SDK开发环境启动Git for Windows项目。新项目主要是由同一个团队开始的。

While many people thought of msysGitas 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 Windowsproject was started with a completely revamped build environment.

虽然许多人认为msysGit是 Git 二进制文件的名称,但实际上这是他们创建的开发环境的名称。它基于 MSYS,这是 MSYS2 重新启动之前的旧版本和过时版本。MSYS 的糟糕状态是Windows项目Git 以完全改造的构建环境启动的原因之一。

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 SDKdoes 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.

该项目基本上发布了三样东西:msysGit、Windows 版 Git 和 Windows 版可移植 Git。msysGit 安装程序将安装和设置在 Windows 上构建 Git 所需的开发环境,就像现在Git for Windows SDK所做的那样。Windows 版 Git 是一个可以在 Windows 机器上安装 Git 的安装程序,而 Windows 版的可移植 Git 只是您不必安装的二进制文件。请注意,它们的所有版本都是作为“预览”版本发布的,这意味着它们不是完全受支持的版本。尽管如此,该项目非常成熟,发布版本非常稳定,事实上是在 Windows 上设置 Git 的最佳方式。

Git Bash

git bash

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

如上所述,很多 Git 都是写成 shell 脚本的。为了执行这些脚本,混帐for Windows使用猛砸是附带了MSYS2(所以猛砸可以作为一个解释器)。

Git Bashcommonly refers to the shortcut the Git for Windowsinstaller 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.

Git Bash通常指的是Git for Windows安装程序创建的快捷方式。它会启动一个运行 Bash 的全功能控制台窗口,因此您可以使用 Git 以及一组常见的命令行工具或 Unix 程序(如lessawkgrep甚至文本编辑器vim)。特别是对于经验不足的用户,Git Bash 是与 Git 交互的常用方式,尽管您可以在更以 Windows 为中心的环境(如PowerShell )中轻松使用它。

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

从 Git 版本 2 开始,Git Bash 将默认在 MinTTY 中启动,MinTTY是 MSYS2 附带的终端模拟器,即使对于不习惯控制台体验的用户也可以轻松使用。

It's also useful to know that Git Bashwill 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 (justthe 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).

即使您决定在设置Git for Windows期间不向 PATH 添加任何 Git 可执行文件,Git Bash也将始终有效,这也很有用。但是,我个人的建议是将 Git 可执行文件(只是Git 可执行文件,在安装过程中选择“从 Windows 命令提示符使用 Git”选项)到 PATH。这样,您可以从其他 shell(cmd.exe 或 PowerShell)使用 Git,其他程序也可以访问它(例如,许多库甚至 IDE 集成都希望 PATH 中的 Git 可执行文件与 Git 存储库交互)。