Windows下的Git:MSYS还是Cygwin?
我计划将我的项目迁移到 git,我目前想知道哪个是 Windows 下最好和/或最稳定的选项。
据我所知,我基本上有 2.5 个选项:
注意:IMO Cygwin 本身就是一个很大的优势,因为您可以访问几乎所有 *nix 命令行工具,而使用 MSYSgit bash 时,您只能访问这些工具的一小部分。
鉴于此,您会建议什么选择?
I plan to migrate my projects over to git, and I'm currently wondering which is the best and / or most stable option under windows.
From what I gather I basically have 2.5 options:
- MSYSgit
- git under Cygwin
- (aka 2.5) MSYSgit from a Cygwin prompt (given that Cygwin git is already installed).
Note: IMO Cygwin in itself is a big plus as you can have access to pretty much all the *nix command line tools, as where with MSYSgit bash, you only have access to a rather small subset of these tools.
Given that, what option would you suggest?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
编辑(两年后:2014 年 10 月)
Johannes Schindelin< /a> 刚刚解释(2014 年 10 月)msysgit已被淘汰:
编辑(3年后:2012年4月)
MsysGit(现在在GitHub上)是你想要的方法Git 世界中的轻量级快速启动:解压存档,启动
git-cmd.bat
或git -bash.bat
就完成了。其最新版本(2012 年 4 月 10 月 7 日) 现在包含支持 UTF-8,还有 包含在 GitExtension 中。
不要忘记将
autocrlf
设置为虽然是假的。如果您确实缺少所有其他 unix 命令而不是 msysgit 软件包,只需下载 GoW(Windows 上的 Gnu ),恰当地命名为“Cygwin 的轻量级替代品”。
我的意思是: 130 unix commands...
Cygwin 应该仅作为某些情况的备份解决方案,例如 大型 Git 存储库的传输速度,如下 incrementor 所提到的在他的回答中。
2012 年 6 月:如果您想与 GitHub 交互,您现在可以使用 http://windows .github.com (另请参阅“设计 GitHub Windows”)。
它不仅会为您配置 ssh 密钥(并将生成的公钥添加到您的 GitHub 配置文件中),而且还会为所有 git 操作安装... MsysGit。
原始答案(2009 年 4 月)
我对最新版本的 MsysGit 没有问题:
我使用选项2,这意味着我只将 git\bin 目录添加到 PATH 环境变量中,但没有覆盖一些内置的 Windows 工具。
我设法定义了外部工具,例如 Notepad++ 和 WinMerge (或 DiffMerge)
我确实成功运行了类似 svn2git 因为,从 MsysGit1.6.2+ 开始,它确实包含“
git svn
”命令。最后,我期待 MsysGit1.6.2.3 最终将包含“
git filter-branch
”命令! (过滤器分支的慢速版本,但仍然如此)。对于 Unix 命令,我更喜欢安装 GnuWin32 coreutils 包,并且仅在需要时使用它们。
总而言之,我没有使用 Cygwin 层,并且在基于 Windows 的版本 MsysGit 中成功地运行了 Git。
Edit (2 more years later: October 2014)
Johannes Schindelin just explained (Oct. 2014) that msysgit is phased out:
Edit (3 years later: April 2012)
MsysGit (now on GitHub) is the way to go if you want a light-weight fast start in Git world: unzip the archive, launch
git-cmd.bat
orgit-bash.bat
and you are done.Its latest release (1.7.10, April 2012) now includes support for UTF-8, also included in GitExtension.
Don't forget to set your
autocrlf
to false though.If you are really missing all the other unix commands not packages with msysgit, simply download a release of GoW (Gnu on Windows), aptly named "The lightweight alternative to Cygwin".
I mean: 130 unix commands...
Cygwin should be a backup solution only for certain cases, like the transfer speed of large Git repositories, as mentioned below by incrementor in his answer.
June 2012: if you want to interact with GitHub, you now have http://windows.github.com (see also "Designing GitHub for Windows").
It not only will configure the ssh keys for you (and add the generated public key to your GitHub profile), but it will also install, for all git operations, a... MsysGit.
Original answer (April 2009)
I have no problem with the latest version of MsysGit:
I use the option 2, which means I only add the git\bin directory to the PATH environment variable, but without overriding some built-in windows tools.
I managed to defined external tools like Notepad++ and WinMerge (or DiffMerge)
I did run successfully scripts like svn2git because, from MsysGit1.6.2+, it does include the '
git svn
' command.And finally I look forward to MsysGit1.6.2.3 for it will include finally '
git filter-branch
' command! (a slow version of filter-branch, but still).For the Unix command, I prefer to install a GnuWin32 coreutils package, and use them only when I need them.
So all in all, I do not use the Cygwin layer, and managed to run Git very well in its Windows-based release MsysGit.
是的。 老问题。 新答案:
我们在大型部署中使用 MSYSgit 已有大约 2 年了。 从本地 git 存储库服务器传输的速度被限制为低于 5 MiB/s。 对该问题的早期调查表明,问题在于 Windows XP 和 Windows 7 上的 MSYS 开发人员安全限制了来自命令提示符/bash shell 的连接。 事实上,这似乎不是问题。
我发现了Darrell Mozingo 的博客文章 并仅使用 Cygwin 安装测试了大型(许多 GiB)存储库的克隆。 传输速度在 30 MiB/s 范围内。 问题是 MSYSgit 使用 2007 年的古董 OpenSSH 二进制文件。
为此,在这个问题得到解决之前,我现在建议转向 Cygwin(尽管 git 的版本有点落后)。 我还发现 Cygwin 更稳定,并且 Perl 不太可能耗尽内存。
Yes. Old question. New answer:
We have been using MSYSgit for about 2 years now in a large deployment. The speed of transfers from a local git repository server have been limited to less than 5 MiB/s. Earlier investigation into the issue indicated that the problem was with MSYS devs being on Windows XP and Windows 7 security limiting connections from command prompt/bash shell. This does not appear to be, in fact, the problem.
I discovered Darrell Mozingo's blog posting and tested a clone of a large (many GiB) repo using only a Cygwin install. Transfer speeds were in the 30 MiB/s range. The problem is that MSYSgit uses an antique OpenSSH binary from 2007.
To this end, until that gets fixed, I am now recommending a shift to Cygwin (even though the version of git is a bit behind). I also found Cygwin to be more stable and less likely for perl to run out of memory.
我尝试过使用 MSYS 和 Cygwin 版本的 git,说实话,我没有发现这两种体验特别好。 我只是认为 git 还没有真正为 Windows 做好准备。
话虽这么说,我发现 MSYS 版本的一个问题是它会将(非二进制)文件的行结尾从 UNIX 样式(换行)转换为 DOS 样式(回车/换行)。 您可能会认为这是一个错误或一个功能,但没有办法改变我能找到的行为。 (编辑:将配置变量 core.autocrlf 设置为 false。谢谢 Brian。)
OTOH,MSYS 版本的 git 有一些 cygwin 中不可用的 GUI 功能版本,除非您想安装并运行整个 X 服务器。 (感谢 Joce 确认这一点。)
我的印象是 MSYS 版本更受欢迎,尽管这可能是因为您不需要安装 cygwin 生态系统来使用它。 (我同意,cygwin 非常有用。)就
个人而言,我会选择 Bazaar 或 Mercurial,两者都对 Windows IMO 有更好的支持。
I've dabbled with using both the MSYS and Cygwin versions of git, and to be really honest, I didn't find either experience especially good. I just don't think git is really ready for windows yet.
That being said, one issue I found with the MSYS version is that it would convert the line-endings on your (non-binary) files from UNIX style (line-feed) to DOS style (carriage-return/line-feed). You may consider this a bug or a feature, but there is no way to change the behaviour that I could find. (EDIT: Set the configuration variable
core.autocrlf
tofalse
. Thanks Brian.)OTOH, the MSYS version of git has some GUI functionality that isn't available in the cygwin version unless you want to install and run a whole X server. (Thanks Joce for confirming this.)
My impression is that the MSYS version is more popular, although that may be because you don't need to install a cygwin ecosystem to use it. (And I agree, cygwin is extremely useful.)
Personally, I would go with either Bazaar or Mercurial, either of which have better support for windows IMO.
Cygwin 和 Msys Git 对于正常用例来说都工作得相当好。 如果您想使用 git-svn 等脚本,Cygwin 是更好的选择。 作为一个最终转向 Linux 的 Windows 老用户,我可以肯定地说 Cygwin 是一个巨大的福音,而且它本身就值得拥有。
不过,背景很重要; 这些是什么项目? 它们被谁使用? ETC。
Both Cygwin and Msys Git work fairly well for normal use-cases. If you want to use scripts such as git-svn, Cygwin is a better bet. As an old Windows users who finally jumped ship to Linux, I can definitely say that Cygwin is a great boon and worth having in and of itself.
Context is important though; what projects are these? Who are they used by? Etc.
我也测试了这两个世界(CygWin 和 MSysgit),我的经验是 MSysgit bash 也存在一些缺点。 无法成功运行 git stash,而 Cygwin 在同一个 git 存储库上优雅地处理它。
不过,尚未进行深入分析...
I've also tested both worlds (CygWin and MSysgit), my experiences is also that there are some shortcomings in the MSysgit bash. Unable to run git stash sucessfully while Cygwin handled it gracefully on the same git repo.
No deep analysis done yet, though...
我目前将 Msysgit 与 TortoiseGit 一起使用。
MsysGit UI 不太符合我的喜好,所以我使用熟悉的工具,如 TortoiseGit,并且在命令行上工作时(大多数时候),我使用 Msysgit 中的 git 二进制文件
I currently use Msysgit together with TortoiseGit.
The MsysGit UI isn't really to my liking so I use a familiar tool like TortoiseGit and when working on the commandline (most of the time), I use the git binary from Msysgit
我推荐 msysgit。 特别是如果它与 Git 扩展 一起使用:它提供了配置环境的简单方法:editor/diff /merge 工具,并允许从用户界面执行高级 git 操作。
I'd recomment msysgit. Especially if it is used with Git Extensions: it provide easy way to configure environment: editor/diff/merge tools, and allows to do advanced git operations from the user interface.
我在 MSys 的 cygwin 实现中遇到了严重的错误:某些命令,尤其是 rebase,很容易失败。 Cygwin 对我来说更稳定。
也就是说,那是一个月前的事,此后可能有所改善。
I have run into serious bugs in MSys's cygwin implementation: some commands, especially the rebase, were quite prone to failure. Cygwin's was much more stable for me.
That said, it was a month ago, might have improved since.
我在 Windows 上使用了 Cygwin Git 和 Msysgit。 我建议使用 Cygwin + Git。 Cygwin 1.7(目前处于测试版)解决了使用 git gui 和 gitk 时的一个主要细微差别(至少对我来说)。 每次我在 git-gui 或 gitk 中执行某些操作时,早期版本的 Cygwin 都会打开 10 个 cmd 窗口。 这已在 1.7 中得到解决。 Cygwin 强大的 shell 也带来了 Linux 终端的许多优点。
也就是说,Msysgit 已经发展了很多并且在 Windows 中非常有用。 不过我遇到了几个问题。
权限问题:在 Windows 中本机创建的一些文件的模式为 755,在使用 Msysgit 时转换为 644。 这将显示为修改后的文件。 签入应该可以解决此问题。
CRLF:像往常一样,难以捉摸的 CRLF 在 Windows 中会产生问题。 Msysgit 可能会报告文件已修改。 这可以通过在安装 Msysgit 时选择“保留行结尾不变”(忘记确切的文本)来解决。
守护进程:是的,我仍然发现在 Msysgit 中设置 git 守护进程很困难。
I have used both Cygwin Git and Msysgit with Windows. I would suggest using Cygwin + Git. Cygwin 1.7 (currently in beta) addresses a major nuance (at least for me) while using git gui and gitk. Earlier versions of Cygwin used to open 10s of cmd windows every time I do something in git-gui or gitk. This has been addressed in 1.7. Cygwin's powerful shell brings in a lot of the goodies of linux terminal as well.
That said, Msysgit has evolved quite a bit and is really useful in Windows. I faced a couple of issues though.
Permission issue: a few files created natively in windows had mode 755 which got converted to 644 while using Msysgit. This would show up as modified files. A checkin should fix this issue.
CRLF: The all elusive CRLF as usual creates issues in Windows. Msysgit might report files as modified. This can be fixed by selecting "Leave line endings unchanged" (forgot the exact text) while installing Msysgit.
Daemon: And yeah I'm still finding it tough to setup git daemon in Msysgit.
老问题的新答案...
我正在 Windows 7 cmd shell 中使用 git 1.7.3,而且效果很好。 我混合使用 git 命令行和 git gui,并且两者都工作了好几个月。 我们确实遇到了回车/换行问题,当我们将 Mac 开发人员添加到团队中时,这些问题变得更加严重,但是这些问题都得到了解决……
并不是说您不应该使用 *nix-y shell,只是说它没有必要。
New answer to an old question ...
I'm using git 1.7.3 from a Windows 7 cmd shell, and it works great. I use a mix of git command line and git gui, and both have been working fine for months. We did have carriage return/line feed issues, exacerbated when we added Mac developers to the team, but these were resolved with ...
Not saying you shouldn't use a *nix-y shell, just that it isn't necessary.
我对 CygWin 持保留态度,因为我只想要 git,而不想要 Cygwin 想要塞入的任何其他工具通常,您希望 Windows 计算机像 Windows 计算机一样工作,而 CygWin 想要提供完全不同的东西。 仅仅为了好玩而使用 *nix 功能是不可行的。
问题是,如果我想使用 *nix 之类的命令行,我会转到我的 Linux 机器并在那台计算机上工作。 虚拟计算机 和 远程桌面如今就像一个魅力,并且对于开发人员来说足够容易访问。
您确实需要有一个使用 CygWin 的正当理由。 如果只是为了使用 git 我建议你使用 MSysGit ,这是我的偏好。 它与捆绑的 gitk 和 git-gui 工具配合得非常好。 我一直在使用 msysgit 开发 Eclipse 和 Visual Studio,它的工作方式就像一个魅力。
我现在唯一等待的是一个完全工作的 Git 的 Tortoise 克隆。
I have reservations towards CygWin because I only want git and not any of the other tools that Cygwin wants to shove in. Normally you want your windows computer to work like a windows computer and CygWin wants to slap on something completely different. Slapping on *nix functionality just for the kicks is not to go.
The thing is, if I ever want to work with *nix like command line, I'd go over to my Linux machine and work on that computer instead. Virtual computers and remote desktops work like a charm nowadays and is accessible enough for developers.
There really needs to be a legitimate reason for you to be using CygWin. If it is just for using git I'd suggest you use MSysGit instead which is my preference. It works really well with the gitk and git-gui tools that are bundled. I've been working on both Eclipse and Visual Studio using msysgit and it works like a charm.
The only thing I'm waiting for now is a fully working Tortoise clone for git.
在 Windows 下有一种情况,您只需必须通过 Cygwin 使用 Git:这是当您想要针对 SVN 服务器使用 Git 时,该服务器需要高于 1.5 的 SVN 客户端版本。 存在 SVN 预提交钩子,当没有“mergeinfo”参数时,它会阻止提交 - 并且“mergeinfo”参数仅在 SVN 1.5 版本中默认。 msysGit 的问题是,它是针对较旧的 SVN 版本(1.4 .6),因此在这种情况下您无法成功提交。 但使用 Cygwin 的 Git 是可能的,因为它是针对较新的 SVN 版本构建的。
There is one scenario under Windows where you simply have to use Git via Cygwin: This is when you want to use Git against a SVN server, which expects SVN client versions higher than 1.5. There exist SVN pre-commit hooks which block commits when there's no 'mergeinfo' argument - and the 'mergeinfo' argument is default in SVN only since version 1.5. The problem with msysGit is, that it is build against an older SVN version (1.4.6), so you can't successfully commit in this case. But it is possible with Cygwin's Git, since it is build against newer SVN versions.
如果您只想执行简单的操作,例如推/拉/分支,您可以尝试 Atlasian 的 SourceTree。 一个非常简单明了的 Git 命令 UI。 然而它也有缺点。
如果您需要使用命令行 git 工具,只需获取 Git for windows 工具即可。 这应该足够了,除非您开始查看 bash 脚本。
If you just want to do simple actions like push/pull/branching you could try SourceTree from Atlasian. A very simple and clear UI for Git command. However it has short coming.
If you need to use the command-line git tool, just get the Git for windows tool. It should be enough, unless you start looking in bash scripting.