Windows 上的 msysgit —— 如果有的话,我应该注意什么?

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

msysgit on windows -- what should I be aware of, if any?

windowsgitversion-controlmsysgit

提问by hasen

This is related to another question I askedrecently.

这与最近问的另一个问题有关。

When installing msysgit, the installer presents 3 options related to system path:

安装 msysgit 时,安装程​​序会提供 3 个与系统路径相关的选项:

  1. Never change windows environment. With this option, you have to use the "bash" shell to work with git.

  2. Add the git\bin directory to the PATH environment variable, but without overriding some builtin windows tools. Fellow stackoverflow-ian Gabe Moothart told me in a commentthat this option will make some git operations fail! What are these operations? Should I worry about them?

  3. Same as 2 but override some default system tools. What are these tools? What parts of windows depend on them? and will this hurt in practice?

  1. 永远不要改变windows环境。使用此选项,您必须使用“bash”外壳来处理 git。

  2. 将 git\bin 目录添加到 PATH 环境变量中,但不要覆盖一些内置的 Windows 工具。stackoverflow-ian Gabe Moothart在评论告诉我这个选项会导致一些 git 操作失败!这些操作是什么?我应该担心他们吗?

  3. 与 2 相同,但会覆盖一些默认系统工具。这些工具是什么?窗户的哪些部分依赖于它们?这在实践中会受到伤害吗?

Another issue has come to my mind, unrelated to the system PATH.

我想到了另一个与系统路径无关的问题。

What if I have symbolic links and hard links inside my project directory? Does git know how to deal with these? or, will it suffer from infinite recursion, if say, the directory structure was such that some folder was actually a symbolic link to one of its parents?

如果我的项目目录中有符号链接和硬链接怎么办?git 知道如何处理这些吗?或者,它是否会受到无限递归的影响,如果说,目录结构是这样的,某个文件夹实际上是到其父文件夹之一的符号链接?

回答by Jonathan Lonowski

You get bashregardless of which option you pick, the latter options just add methods for using Git outside it.

bash无论你选择哪个选项,你都会得到,后一个选项只是添加了在它之外使用 Git 的方法。

For the latter options, msysgitadds Windows builds of common Linux utilities to PATH. This includes find, killand sort, as well as cp, ls, rm, and about 20-30 others.

对于后一个选项,msysgit将常见 Linux 实用程序的 Windows 版本添加到PATH. 这包括findkillsort,以及cplsrm,和大约20-30人。

The problem with the first 3 (and similar) is that they exist in both OSs and function differently in each.

前 3 个(和类似的)的问题在于它们存在于两个操作系统中,并且在每个操作系统中的功能都不同。

Not a huge ordeal if you know which one you'll be using, but any applications developed expecting one and getting the other will surely throw a fit.

如果您知道将使用哪一个,这不是一个巨大的考验,但是任何开发的应用程序都期待一个并获得另一个肯定会大吃一惊。



To prevent the conflict, while still having Git work as expected, you can create a simple batch script that adjusts PATHonly for the session. (e.g., readygit.bat)

为了防止冲突,同时让 Git 按预期工作,您可以创建一个PATH仅针对会话进行调整的简单批处理脚本。(例如,readygit.bat

@echo off
setlocal
set PATH=C:\Git\bin;%PATH%
cmd

Adjust C:\Git\binaccordingly. But, just run this and use Git within the cmd.

相应调整C:\Git\bin。但是,只需运行它并在cmd.

With this, you can use install option 3 and safely remove C:\Git\binfrom your system's PATH, removing any confusion for Windows apps without confusing Git.

有了这个,您可以使用安装选项 3 并安全地C:\Git\bin从您的系统中删除PATH,消除对 Windows 应用程序的任何混淆,而不会混淆 Git。

I currently use a similar script with GnuWinapps, including find.

我目前在GnuWin应用程序中使用类似的脚本,包括find.

回答by VonC

You may want to be aware that:

您可能想知道:

  • All git commands are not still there. On MSysGit1.6.2 early March 2009: archimport, cvsexportcommit, cvsimport, cvsserver, filter-branch, instaweb, send-email, and shell.)

  • Until MSysGit1.6.2, git-svn was not there(it is now).
    The problem was git-svn needed subversion's perl bindings, and you can only build them as dynamically loadable modules. And MSysGit had a perl version that did not support dynamically loadable modules.

  • All details about MSysGit are best explained in their MSysGitHeraldGithub wiki

  • 所有 git 命令都不再存在。在 2009 年 3 月上旬的 MSysGit1.6.2 上:archimport、cvsexportcommit、cvsimport、cvsserver、filter-branch、instaweb、send-email 和 shell。)

  • 在 MSysGit1.6.2 之前,git-svn不存在现在是)。
    问题是 git-svn 需要 subversion 的 perl 绑定,并且您只能将它们构建为可动态加载的模块。而且 MSysGit 有一个不支持动态加载模块的 perl 版本。

  • 关于 MSysGit 的所有细节都在他们的MSysGitHeraldGithub wiki 中得到了最好的解释

回答by Arafangion

On windows (this is less of an issue on other systems, in my very humble opinion...), you must be VERY aware of crlf issues, and note that (Unless they've changed this in the very latest version of Git, which I believe they may have - or if you're using a very old version of Git), autocrlf is enabled by default, unlike all the other git installations.

在 Windows 上(在我看来,这在其他系统上不是什么问题……),您必须非常了解 crlf 问题,并注意(除非他们在最新版本的 Git 中对此进行了更改,我相信他们可能有 - 或者如果您使用的是非常旧版本的 Git),默认情况下启用 autocrlf,与所有其他 git 安装不同。

Also note that unless you use the very latest version of msysgit, soon to be out this week if I recall correctly from the mailing list, your repository size can not be larger than 2GB, total.

另请注意,除非您使用最新版本的 msysgit,如果我从邮件列表中没记错的话,本周很快就会发布,您的存储库大小不能超过 2GB,总计。

Additionally, Windows is wierdly case insensitive but /sometimes/ case preserving - keep that in mind! (This does not confuse git neccessarily - but it can and does confuse the user of the git repo).

此外,Windows 非常不区分大小写,但 / 有时 / 保留大小写 - 请记住这一点!(这并不一定会混淆 git - 但它可以并且确实会混淆 git repo 的用户)。

Finally, git is substantially slower on windows than it is on linux, although it is (in my limited experience) faster than the alternatives.

最后,git 在 windows 上比在 linux 上慢得多,尽管它(以我有限的经验)比替代品快。

Now, regarding the path...

现在,关于路径...

Unless I'm mistaken, you should be able to just ensure that the main git binary is in the path - and that binary should then take care of referencing the other git components... But I have not tested this.

除非我弄错了,否则您应该能够确保主 git 二进制文件在路径中 - 然后该二进制文件应该负责引用其他 git 组件......但我没有对此进行测试。

回答by Gabe Moothart

The MSYS Git installer suggests option 2 if you intend on running git from a cygwin prompt. The cygwin environment ensures that git dependencies are in your PATH. If you choose this option but then invoke git from a windows command prompt, all of the unix-y command-line utilities that git relies upon will not be found. IIRC, git itself is partially implemented as bash scripts. I don't know which operations will fail, but I do not think that git will be usable this way.

如果您打算从 cygwin 提示符运行 git,MSYS Git 安装程序会建议选项 2。cygwin 环境确保 git 依赖项在您的 PATH 中。如果您选择此选项,然后从 Windows 命令提示符调用 git,则将找不到 git 依赖的所有 unix-y 命令行实用程序。IIRC,git 本身部分实现为 bash 脚本。我不知道哪些操作会失败,但我认为 git 不会以这种方式使用。

I don't have a list of the system tools that option 3 overrides (the installer mentions find.exe) but this would only affect you if you are a batch-script ninja. At the command-line, findwill now refer to the unix utility of that name, not the exe that ships with windows. It doesn't harm windows itself in any way.

我没有选项 3 覆盖的系统工具列表(安装程序提到 find.exe),但这只会影响您如果您是批处理脚本忍者。在命令行中,find现在将引用该名称的 unix 实用程序,而不是 Windows 附带的 exe。它不会以任何方式损害窗户本身。

Just run with scissors and choose option 3 :-)

只需用剪刀运行并选择选项 3 :-)

回答by Gabe Moothart

When you use the Windows GUI on windows, and you create your very first repository, do not type in the name ".git" for the repository directory. (Which it will then create, and then create another .git folder underneath it, when you finally think to look there) Browse to the folder with your sources in it, and -- just choose that folder! The repository directory ".get" will be created FOR you.

当您在 Windows 上使用 Windows GUI 并创建您的第一个存储库时,不要为存储库目录键入名称“.git”。(然后它会创建,然后在它下面创建另一个 .git 文件夹,当你终于想看那里时)浏览到包含你的源代码的文件夹,然后——选择那个文件夹!将为您创建存储库目录“.get”。

Then you see files in your unstaged changes, and by clicking on the little page icons next to the filenames, move them into the staged changes.

然后您会看到未暂存更改中的文件,并通过单击文件名旁边的小页面图标,将它们移动到暂存更改中。

And definitely run with scissors and select option 3. No one uses kill, sort or find anymore from the command windows line.

并且绝对用剪刀运行并选择选项 3。没有人在命令行窗口中使用 kill、sort 或 find 了。