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

发布于 2024-07-14 14:58:23 字数 696 浏览 12 评论 0原文

这与我最近提出的另一个问题相关。

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

  1. 永远不要更改 Windows 环境。 使用此选项,您必须使用“bash”shell 才能使用 git。

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

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

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

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

This is related to another question I asked recently.

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

  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 comment that 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?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

笛声青案梦长安 2024-07-21 14:58:23

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

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

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

如果您知道自己将使用哪一个,这并不是一个巨大的考验,但是任何开发的应用程序都期望其中一个而得到另一个,肯定会引起不适。


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

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

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

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

我目前在 GnuWin 应用程序中使用类似的脚本,包括 <代码>查找

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

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

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

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 PATH only for the session. (e.g., readygit.bat)

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

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

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

I currently use a similar script with GnuWin apps, including find.

转角预定愛 2024-07-21 14:58:23

您可能需要注意:

  • 并非所有 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 的所有详细信息,最好在其 MSysGitHerald Github wiki 中进行解释< /a>

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 MSysGitHerald Github wiki

浅唱ヾ落雨殇 2024-07-21 14:58:23

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

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

此外,Windows 奇怪地不区分大小写,但/有时/保留大小写 - 请记住这一点! (这不一定会让 git 感到困惑 - 但它可以而且确实会让 git 存储库的用户感到困惑)。

最后,git 在 Windows 上比在 Linux 上慢得多,尽管它(以我有限的经验)比其他替代方案更快。

现在,关于路径...

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

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.

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.

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

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

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.

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

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

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

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.

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, find will 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.

Just run with scissors and choose option 3 :-)

能怎样 2024-07-21 14:58:23

当您在 Windows 上使用 Windows GUI 并创建第一个存储库时,请勿输入存储库目录名称“.git”。 (然后,当您最终想要查看该文件夹时,它将创建该文件夹,然后在其下创建另一个 .git 文件夹)浏览到其中包含源代码的文件夹,然后 - 只需选择该文件夹即可! 将为您创建存储库目录“.get”。

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

并且一定要使用剪刀运行并选择选项 3。没有人再从命令行窗口中使用kill、sort或find。

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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文