Windows的git软件包管理?

问题描述 投票:41回答:4

我正在github上阅读wiki上的git,它说msys2捆绑了pacman:https://github.com/git-for-windows/git/wiki/Package-management

但是当我调用它时:

$ pacman
bash: pacman: command not found

有人知道发生了什么吗?该Wiki指向哪个git版本?有没有办法在Windows的Git内将其他软件包安装到msys2?

windows git bash msysgit msys
4个回答
36
投票

issue 397中所述:

这是有意的。我们不为Windows的Git附带pacman。如果您对完全成熟的Package Manager维护环境感兴趣,则必须尝试Git for Windows SDK

您在latest git for Windows (2.5.3)中看到的bash是more recent bash than the old msysgit one,仅在其中执行git命令。安装任何第三方软件包都不是成熟的linux环境。


20
投票

Windows的Git(https://gitforwindows.org/https://git-scm.com/downloads)(具有Git Bash),但不包括treetree可通过pacman(程序包管理器)使用,但仅当您安装“ Git for Windows SDK”时可用(滚动到https://gitforwindows.org/的底部,该链接提供了下载安装程序的链接)来自https://github.com/git-for-windows/build-extra/releases/latest

此SO:“ Windows的git软件包管理?”很有帮助Package management in git for windows?

也正如上述SO中所述,它们链接到Windows的git问题[在新的2.5.2安装#397中缺少吃豆子],其默认安装中不包含pacman

无论如何,我安装了“ Git for Windows SDK”,然后在bash提示符(SDK-64)中运行了以下安装当前树v1.7.0-1(截至2018年8月30日发布):

[SDK-64: Bash Terminal for Git for Windows SDK]
pacman -S tree
...
Proceed with installation? [Y/n] Y

[在我的系统上,用于Windows SDK的Git安装在以下位置:C:\git-sdk-64,因此从我的Windows Bash Shell的Git(未安装树)中,我通过tree.exe将其复制到/ usr / bin目录,例如

[MINGW64: Bash Terminal for Git for Windows]
cd /usr/bin
cp /c/git-sdk-64/usr/bin/tree.exe .

现在我可以从两个Git Bash外壳程序中运行tree v1.7.0。

因此,为了让其他人甚至可能是我自己在将来的机器上变得更容易,我通过在Windows SDK Bash终端程序的Git中运行以下命令,查看pacmantree软件包中获取的位置:

$ pacman -S --info tree
Repository      : msys
Name            : tree
Version         : 1.7.0-1
Description     : A directory listing program displaying a depth indented list of files
Architecture    : x86_64
...

关键是,这里的pacman是从“ msys”存储库中获取的(仅供参考:即使它说的是msys,它确实在使用msys2),所以我查看了/etc/pacman.d/mirrorlist.msys,第一个镜像指向http://repo.msys2.org/msys/$arch/

因此,下一次您想要的软件包不在Windows的Git中时,可以从http://repo.msys2.org/msys/x86_64/(对于64位)或http://repo.msys2.org/msys/i686/(32位)下载它们

例如树的直接下载链接v1.7.0-1

FYI:在https://git-scm.com/download/处下载Git SCM的Window,从Git for Windows GitHub获取最新信息(https://github.com/git-for-windows/githttps://github.com/git-for-windows/git/releases/链接中获得]


10
投票

我不想从已经可以使用的Git for Windows安装中移出,所以我做了一些即兴的表演:

  1. 在其他地方安装Windows SDK的Git。您将需要3 GB以上的可用空间。
  2. ${git-sdk}/usr/bin/pacman.exe复制到${git}/usr/bin
  3. ${git-sdk}/etc/pacman.conf${git-sdk}/etc/pacman.d复制到${git}/etc
  4. ${git-sdk}/var复制到${git}/

就这些。现在,您可以打开Git Bash并运行pacman -S python在现有的Windows Git安装程序上安装软件包。

您将需要对Windows的Git目录具有写权限。另外,您的pacman现在认为它(从SDK)安装了很多软件包,但并没有阻止我使用它。


6
投票

似乎有documented way来执行此操作,而不必安装Git for Windows SDK(非常大)。当我在GitHub issue #1912上询问所有这些问题时,PhilipOakley给予了我此信息的链接。

这是有关Windows GitHub的Git的当前文本,wiki page

在MSYS2内部正确安装

请注意,Windows的Git并不正式支持此方案

(不支持此操作的原因是,没有志愿者支持该方案。]

[本指南假定您想要Windows的64位版本的Git。

基于Windows的Git基于MSYS2,可以将git软件包安装到现有的MSYS2安装中。这意味着,如果您已经在计算机上使用MSYS2,则可以使用Git for Windows,而无需运行完整的安装程序或使用便携式版本。

但是请注意,使用这种方式有些注意事项。 Windows的Git为msys2-runtime创建了一些尚未向上游发送的补丁。 (这已经计划好了,但是在问题#284中确定它可能不会发生。)这意味着您必须安装Windows自定义msys2-runtime的Git,才能在MSYS2中拥有完全正常的git。

这里是要采取的步骤:

  1. 打开MSYS2终端。

  2. 编辑/etc/pacman.conf并在[mingw32]之前(我的机器上的第71行),添加git-for-windows软件包存储库:

[git-for-windows] Server = https://wingit.blob.core.windows.net/x86-64

以及可选的opposite体系结构的仅限MINGW的存储库(即64位SDK的MINGW32):

[git-for-windows-mingw32] Server = https://wingit.blob.core.windows.net/i686

  1. 授权签名密钥(此步骤有时可能需要重复执行,直到固定https://github.com/msys2/msys2/issues/62为止]

curl -L https://raw.githubusercontent.com/git-for-windows/build-extra/master/git-for-windows-keyring/git-for-windows.gpg | pacman-key --add - && pacman-key --lsign-key 1A9F3986

  1. 然后同步新存储库

pacboy update

  1. 此更新msys2-runtime,因此将要求您关闭窗口(not退出pacman进程)。不要惊慌,只需关闭所有当前打开的MSYS2 shell和MSYS2程序。仔细检查任务管理器,并关闭窗口后杀死pacman.exe它仍在运行,因为它可能会持续存在。全部关闭后,再次启动新的终端。

  2. 然后再次同步[[再次(更新软件包的非核心部分):

pacboy update

    最后安装Git / cURL软件包:
  • pacboy sync git:x git-doc-html:x git-doc-man:x git-extra: curl:x

      最后,通过在MINGW64 shell中执行git --version来检查一切是否正常,它应该输出类似git version 2.14.1.windows.1(或更高版本)的内容。
  • © www.soinside.com 2019 - 2024. All rights reserved.