使用 Cygwin 或 msysGit 版本的 Git,还是两者都使用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8371676/
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-19 06:13:37  来源:igfitidea点击:

Use Cygwin or msysGit version of Git, or both?

gitcygwinmsysgit

提问by JasonDavis

I am running Windows 7, I just installed Cygwin for the first time today so I have been playing around with it. I am now wanting to start using Git as well.

我正在运行 Windows 7,我今天第一次安装了 Cygwin,所以我一直在玩它。我现在也想开始使用 Git。

From what I have read msysGit will allow you to use a GUI, and it also adds a right click on a folder/file Add to Git GUIand Add to GIT Bashcontext menu options.

从我读过的内容来看,msysGit 将允许您使用 GUI,并且它还添加了对文件夹/文件Add to Git GUIAdd to GIT Bash上下文菜单选项的右键单击。

At the same time though I would like to use the command line to do some Git stuff but I think as a Git beginner it would be nice to have the context menus and a GUI.

同时,虽然我想使用命令行来做一些 Git 的事情,但我认为作为一个 Git 初学者,拥有上下文菜单和 GUI 会很好。

So I am kind of stuck. Couple of questions...

所以我有点卡住了。几个问题...

  1. If I install Git with msysGit can I still run the command line stuff for Git with Cygwin?

  2. One book said that you can install both Cygwin and msysGit it versions, if that is the case, do they both work on the same files/repo or is it like having 2 separate Git repos on every file? If that is the case then it seems like overkill.

  3. I also saw that msysGit has a portable version. If I were to use this portable version, does that mean that the Git repo is stored on the USB portable device or just the program? It would be cool if it is the Git program and the code repo stored portable.

  1. 如果我用 msysGit 安装 Git,我还能用 Cygwin 运行 Git 的命令行吗?

  2. 一本书说你可以同时安装 Cygwin 和 msysGit it 版本,如果是这种情况,它们是否都在同一个文件/存储库上工作,或者每个文件都有 2 个单独的 Git 存储库?如果是这样的话,那似乎有点矫枉过正了。

  3. 我还看到 msysGit 有一个便携式版本。如果我要使用这个便携式版本,这是否意味着 Git 存储库是存储在 USB 便携式设备上还是仅存储在程序上?如果它是 Git 程序并且代码存储库可移植,那就太酷了。

采纳答案by manojlds

1) If you are not using cygwin for anything else, and you want to use Git, go with msysgit. It brings in good Git integration to Windows and almost all GUI tools - Git Extensions, TortoiseGit and others that I know of, are dependent on msysgit. Also with msysgit, you can use git from cmd, powershell etc. which is not possible if you only have cygwin git.

1) 如果您不将 cygwin 用于其他任何用途,而您想使用 Git,请使用 msysgit。它为 Windows 和几乎所有 GUI 工具带来了良好的 Git 集成——Git Extensions、TortoiseGit 和我所知道的其他工具都依赖于 msysgit。同样使用 msysgit,您可以使用来自 cmd、powershell 等的 git,如果您只有 cygwin git,这是不可能的。

msysgit comes with it's own bash and you can use that for command line and you won't need cygwin ( again, from point of you not using cygwin for other things). Almost all git features are available in msysgit and except for some Windows specific changes ( and performance), you will find that everything works in a comparable way to git on *nix. cygwin will not be as performant as msysgit and much less native git on *nix.

msysgit 带有它自己的 bash,您可以将其用于命令行,并且不需要 cygwin(同样,从您不将 cygwin 用于其他事情的角度来看)。几乎所有 git 功能都在 msysgit 中可用,除了一些特定于 Windows 的更改(和性能),您会发现一切都以与 *nix 上的 git 类似的方式工作。cygwin 的性能不如 msysgit,更不如 *nix 上的原生 git。

2) And it is possible to have them both and you don't need separate repos. They can co-exist peacefully.

2)并且可以同时拥有它们并且您不需要单独的回购。他们可以和平共处。

3) Git repos are lightweight as they only involve filesystem. There is no concept of portable git repos, as they are effectively portable. Msysgit portable is meant to allow you to operate on Git repos on a system without installing msysgit.

3) Git repos 是轻量级的,因为它们只涉及文件系统。没有便携式 git repos 的概念,因为它们是有效的便携式。Msysgit 可移植性旨在允许您在不安装 msysgit 的情况下对系统上的 Git 存储库进行操作。

回答by Keith Thompson

You can use either or both -- but there are some things to watch out for.

您可以使用其中一个或两者 - 但有一些事情需要注意。

At my most recent job, most of the team was using msysGit; I used Cygwin git because I'm a heavy Cygwin user anyway.

在我最近的工作中,大部分团队都在使用 msysGit;我使用 Cygwin git 因为无论如何我都是 Cygwin 的重度用户。

The two treat execute permissions differently. When you checkout a foo.cmdor foo.batfile in the MSYS environment, it treats it as executable because the .cmdor .batsuffix denotes an executable format. Cygwin doesn't; it's a Unix-like environment, so it doesn't assume that a file is executable based on its suffix. So the *.cmdfiles were working fine for everyone else, but not for me.

两者对待执行权限的方式不同。当您在 MSYS 环境中检出foo.cmdfoo.bat文件时,它会将其视为可执行文件,因为.cmdor.bat后缀表示可执行格式。Cygwin 没有;它是一个类 Unix 环境,因此它不假定文件是基于其后缀的可执行文件。所以这些*.cmd文件对其他人都很好,但对我来说却不是。

The workaround was to do a chmod +xand check in and push the change, which made the files executable for me and didn't affect other users.

解决方法是执行chmod +x并签入并推送更改,这使得文件对我来说是可执行的,并且不会影响其他用户。

I also ran into some problems with entering passwords when doing push, pull, or fetch; the code in git that turns off echoing works under MSYS, but not under Cygwin. I was able to avoid that by using passwordless ssh.

在执行push, pull, 或时,我也遇到了输入密码的一些问题fetch;git 中关闭回显的代码在 MSYS 下有效,但在 Cygwin 下无效。我能够通过使用无密码 ssh 来避免这种情况。

Apart from that (and perhaps one or two other issues that I'm not remembering at the moment), things went reasonably smoothly.

除此之外(也许还有一两个我现在不记得的其他问题),事情进展得相当顺利。

回答by dahlbyk

Git for cygwin and msysGit install completely separate executables. The former only works within cygwin; the latter installs its own bash shell (and GUI tools) but can also work from cmd.exe or PowerShell. I personally prefer msysGit.

用于 cygwin 和 msysGit 的 Git 安装完全独立的可执行文件。前者仅在 cygwin 中有效;后者安装自己的 bash shell(和 GUI 工具),但也可以从 cmd.exe 或 PowerShell 运行。我个人更喜欢 msysGit。

Both will work against the same Git repositories.

两者都适用于相同的 Git 存储库。

回答by Carl

If by some unlucky twist of fate, you're dealing with a git repository where some commits in its history are say, a few gigs in size, then you will run out of memory with MSysGit, because as of right now, only a 32-bit version is available (there is a 64bit version that is in Pre-apha, but as of right now, it still fails some test and is therefore not suitable for production). Only in this situation does a 64 bit version of Git become a necessity.

如果由于某种不幸的命运转折,您正在处理一个 git 存储库,其中一些历史上的提交被说成是几场演出,那么您将用 MSysGit 耗尽内存,因为截至目前,只有 32 -bit 版本可用(Pre-apha 中有一个 64 位版本,但截至目前,它仍然无法通过一些测试,因此不适合生产)。只有在这种情况下,64 位版本的 Git 才成为必要。

UPDATE: There is a way by which you can still use 64bit Git without going the Cygwin route:

更新:有一种方法可以让您在不走 Cygwin 路线的情况下仍然使用 64 位 Git:

  1. Install Vagrant
  2. Install VirtualBox
  3. Add this VagrantFileto an empty folder
  4. Tweak it to your needs
  5. On the command prompt cd to the new folder and
    1. Issue the command "vagrant up". Grab a coffee while this completes.
    2. Next, issue the command "vagrant ssh"
  1. 安装流浪汉
  2. 安装VirtualBox
  3. 将此VagrantFile添加到空文件夹中
  4. 根据您的需要进行调整
  5. 在命令提示符 cd 到新文件夹和
    1. 发出命令“vagrant up”。完成后喝杯咖啡。
    2. 接下来,发出命令“vagrant ssh”

You now have a Linux virtual machine with 64-bit git installed. Next, within the virtual machine:

您现在拥有一个安装了 64 位 git 的 Linux 虚拟机。接下来,在虚拟机中:

  1. cd /vagrant
  2. git clone
  1. CD /流浪者
  2. git 克隆

Let it complete and you will have a 64 bit installation of Git controlling your repository on Windows.

让它完成,你将有一个 64 位的 Git 安装来控制你在 Windows 上的存储库。

回答by WinWin

By all means do NOT install cygwin's git. It's slow to death. I am about to try msysgit, hoping for a saner performance.

无论如何不要安装 cygwin 的 git。很慢。我即将尝试 msysgit,希望有一个更理智的表现。

回答by wkl

You might be confusing gitthe tool with git repos. msysgit and cygwin git provide the tools, the repositories can exist independently of having gitbinaries around.

您可能会git将该工具与 git repos混淆。msysgit 和 cygwin git 提供了工具,存储库可以独立于git周围的二进制文件而存在。

1 - Yes. msysgit is an implementation of git that uses MSYS, and has higher performance than Cygwin git. msysgit has command line git.exeexecutables as well. msysgit will not depend on other things, and you can run it from regular cmd.

1 - 是的。msysgit 是使用 MSYS 的 git 实现,性能比 Cygwin git 更高。msysgit 也有命令行git.exe可执行文件。msysgit 不依赖于其他东西,您可以从常规cmd.

Cygwin's git will have dependencies on the Cygwin system, and is slow compared to msysgit.

Cygwin 的 git 会依赖 Cygwin 系统,并且比 msysgit 慢。

You can, however, have both installed, but if you don't use cygwin for anything else, it's not necessary to install it just for git. I strongly favor msysgit here.

但是,您可以同时安装两者,但是如果您不将 cygwin 用于其他任何用途,则没有必要仅为 git 安装它。我在这里强烈支持 msysgit。

2 - git is git, you can use msysgit or cygwin's git for the same repositories, though be careful of version mismatches (like if you're using msysgit 1.7.8 and cygwin git 1.6). I don't think it's a big problem but I've never had multiple git versions installed.

2 - git 是 git,您可以将 msysgit 或 cygwin 的 git 用于相同的存储库,但要注意版本不匹配(例如,如果您使用的是 msysgit 1.7.8 和 cygwin git 1.6)。我不认为这是一个大问题,但我从未安装过多个 git 版本。

edit:

编辑:

3 - msysgit portable means you can carry msysgit around on something like a flash drive.

3 - msysgit 便携意味着您可以将 msysgit 随身携带在闪存驱动器之类的东西上。

Extra:

额外的:

You might want to give TortoiseGita try. It's a GUI for git, and gives you context menus for doing git stuff in the Windows Explorer. You do need to have msysgit installed before installing TortoiseGit.

您可能想尝试一下TortoiseGit。它是 git 的 GUI,并为您提供了在 Windows 资源管理器中执行 git 内容的上下文菜单。在安装 TortoiseGit 之前,您确实需要安装 msysgit。