git for windows 中的包管理?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32712133/
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
Package management in git for windows?
提问by carbolymer
I'm reading wiki on github for git and it says that msys2 bundles pacman: https://github.com/git-for-windows/git/wiki/Package-management
我正在 github 上为 git 阅读 wiki,它说 msys2 捆绑了 pacman:https: //github.com/git-for-windows/git/wiki/Package-management
But when i'm invoking it:
但是当我调用它时:
$ pacman
bash: pacman: command not found
Does anyone has an idea what is going on? To which git version this wiki refers? Is there a way to install additional packages to msys2 inside Git for windows?
有谁知道发生了什么?这个 wiki 指的是哪个 git 版本?有没有办法在 Windows 的 Git 中为 msys2 安装额外的软件包?
采纳答案by VonC
As mentioned in issue 397:
This is intended. We do not ship pacman with Git for Windows.
If you are interested in a fully fledged package manager maintained environment you have to give the Git for Windows SDKa try.
这是有意的。我们不随 Git for Windows 提供 pacman。
如果您对完全成熟的包管理器维护环境感兴趣,您必须尝试使用Git for Windows SDK。
The bash that you see in the latest git for Windows (2.5.3), which is a more recent bash than the old msysgit one, is only there to execute git commands.
It is not a full-fledged linux environment to install any third-party package.
您在看到bash的最新混帐的Windows(2.5.3) ,这是一个更近的bash比老msysgit一个,只是没有执行Git命令。
安装任何第三方软件包都不是成熟的 linux 环境。
回答by N. Ngo
Git for Windows (https://gitforwindows.org/or https://git-scm.com/downloads) (has Git Bash) but it does not include tree
. tree
is available for via pacman
(Package Manager) but that is only available if you install "Git for Windows SDK" (scroll to the bottom of https://gitforwindows.org/which provides a link to download installer for it from https://github.com/git-for-windows/build-extra/releases/latest)
Windows 版 Git(https://gitforwindows.org/或https://git-scm.com/downloads)(有 Git Bash)但不包括tree
. tree
可通过pacman
(包管理器)使用,但仅当您安装“Git for Windows SDK”时才可用(滚动到https://gitforwindows.org/的底部,它提供了从https://下载安装程序的链接)github.com/git-for-windows/build-extra/releases/latest)
This SO: "Package management in git for windows?" was very helpful Package management in git for windows?
这个 SO:“Windows 的 git 中的包管理?” 在 git for windows 中进行包管理很有帮助 吗?
Also as commented in the above SO, they link to this git for windows issue [Pacman missing on fresh 2.5.2 install #397] that it was intended to not include pacman
in the default install.
同样如上述 SO 中所述,他们链接到此 git 以解决 Windows 问题 [Pacman 在新的 2.5.2 install #397 中丢失],它旨在不包含pacman
在默认安装中。
Anyways, I installed "Git for Windows SDK", then in it's bash prompt (SDK-64) I ran the following to install current tree v1.7.0-1 (as of this posting Aug 30, 2018):
无论如何,我安装了“Git for Windows SDK”,然后在它的 bash 提示符 (SDK-64) 中运行以下命令来安装 current tree 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
On my system, Git for Windows SDK is installed under: C:\git-sdk-64
, so from my Git for Windows Bash shell (that did not have tree installed), I copied it over tree.exe to it's /usr/bin directory, e.g.
在我的系统上,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 .
Now I can run tree
v1.7.0 from both Git Bash shells.
现在我可以tree
从两个 Git Bash shell运行v1.7.0。
So, to make it even easier for others and maybe myself on a future machine, I looked at where pacman
was getting the tree
package from by running following in my Git for Windows SDK Bash terminal:
因此,为了让其他人甚至我自己在未来的机器上更轻松,我通过在我的 Git for Windows SDK Bash 终端中运行以下命令来查看从哪里pacman
获取tree
包:
$ 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
...
The key thing, here is that pacman
is getting it from the "msys" repository (FYI: even though it says msys, it really is using msys2), so I looked at /etc/pacman.d/mirrorlist.msys
and the first mirror points to http://repo.msys2.org/msys/$arch/
关键是,这是pacman
从“msys”存储库中获取它的(仅供参考:尽管它说的是 msys,但它确实在使用 msys2),所以我查看/etc/pacman.d/mirrorlist.msys
了第一个镜像指向http://repo.msys2.org/msys/$arch/
So next time you want a package that is NOT in Git for Windows, you can download them from: http://repo.msys2.org/msys/x86_64/(for 64-bit) or from http://repo.msys2.org/msys/i686/(32-bit)
因此,下一次你想有一个包,是不是在为Git的Windows,可以下载它们:http://repo.msys2.org/msys/x86_64/(64位)或HTTP://repo.msys2 .org/msys/i686/(32 位)
e.g. direct download link for tree v1.7.0-1
例如树 v1.7.0-1 的直接下载链接
- 64-bit: http://repo.msys2.org/msys/x86_64/tree-1.7.0-1-x86_64.pkg.tar.xz
- or https://sourceforge.net/projects/msys2/files/REPOS/MSYS2/x86_64/tree-1.7.0-1-x86_64.pkg.tar.xz
- 32-bit: http://repo.msys2.org/msys/i686/tree-1.7.0-1-i686.pkg.tar.xz
- or https://sourceforge.net/projects/msys2/files/REPOS/MSYS2/i686/tree-1.7.0-1-i686.pkg.tar.xz
- 64 位:http: //repo.msys2.org/msys/x86_64/tree-1.7.0-1-x86_64.pkg.tar.xz
- 或https://sourceforge.net/projects/msys2/files/REPOS/MSYS2/x86_64/tree-1.7.0-1-x86_64.pkg.tar.xz
- 32 位:http: //repo.msys2.org/msys/i686/tree-1.7.0-1-i686.pkg.tar.xz
- 或https://sourceforge.net/projects/msys2/files/REPOS/MSYS2/i686/tree-1.7.0-1-i686.pkg.tar.xz
FYI: Git SCM's Window's download at https://git-scm.com/download/pulls the latest from Git for Windows GitHub (https://github.com/git-for-windows/gitfrom the https://github.com/git-for-windows/git/releases/link)
FYI:Git的SCM的窗口的下载在https://git-scm.com/download/翻出从SVN为Windows GitHub上(最新https://github.com/git-for-windows/git从https://开头的github .com/git-for-windows/git/releases/链接)
回答by Chulup
I did not want to move from my already working Git for Windows installation so I improvised a bit:
我不想从我已经在工作的 Git for Windows 安装中移动,所以我即兴创作了一点:
- Install Git for Windows SDK somewhere else. You'll need more than 3 GB of free space for that.
- Copy
${git-sdk}/usr/bin/pacman.exe
to${git}/usr/bin
- Copy
${git-sdk}/etc/pacman.conf
and${git-sdk}/etc/pacman.d
to${git}/etc
- Copy
${git-sdk}/var
to${git}/
- 在其他地方安装适用于 Windows SDK 的 Git。为此,您需要 3 GB 以上的可用空间。
- 复制
${git-sdk}/usr/bin/pacman.exe
到${git}/usr/bin
- 复制
${git-sdk}/etc/pacman.conf
和${git-sdk}/etc/pacman.d
到${git}/etc
- 复制
${git-sdk}/var
到${git}/
That's all. You can now open your Git Bash and run pacman -S python
to install packages on your existing Git for Windows setup.
就这样。您现在可以打开 Git Bash 并运行pacman -S python
以在现有 Git for Windows 设置上安装软件包。
You will need write access to Git for Windows directory. Also, your pacman
now thinks it has a lot of packages installed (from SDK) but it did not stop me from using it.
您将需要对 Git for Windows 目录的写访问权限。此外,您pacman
现在认为它安装了很多软件包(来自 SDK),但这并没有阻止我使用它。
回答by MikeBeaton
There seems to be a documented wayto do this without having to install the Git for Windows SDK (which is very large). I was given the link to this info by PhilipOakley when I asked about all this on GitHub issue #1912.
似乎有一种文档化的方法可以做到这一点,而无需安装 Git for Windows SDK(非常大)。当我在 GitHub issue #1912上询问所有这些时,PhilipOakley 给了我这个信息的链接。
Here's the current text of the Git for Windows GitHub wiki pageabout it:
这是 Git for Windows GitHub wiki 页面的当前文本:
Install inside MSYS2 proper
Please note that this scenario is not officially supported by Git for Windows
(The reason this is unsupported is that there are no volunteers to support that scenario.)
This guide assumes that you want the 64-bit version of Git for Windows.
Git for Windows being based on MSYS2, it's possible to install the
git
package into an existing MSYS2 installation. That means that if you are already using MSYS2 on your computer, you can use Git for Windows without running the full installer or using the portable version.Note however that there are some caveats for going this way. Git for Windows created some patches for
msys2-runtime
that have not been sent upstream. (This had been planned, but it was determined in issue #284that it would probably not be happening.) This means that you have to install Git for Windows customizedmsys2-runtime
to have a fully working git inside MSYS2.Here the steps to take:
Open an MSYS2 terminal.
Edit
/etc/pacman.conf
and just before[mingw32]
(line #71 on my machine), add thegit-for-windows
packages repository:
[git-for-windows] Server = https://wingit.blob.core.windows.net/x86-64
and optionally also the MINGW-only repository for the oppositearchitecture (i.e. MINGW32 for 64-bit SDK):
[git-for-windows-mingw32] Server = https://wingit.blob.core.windows.net/i686
- Authorize signing key (this step may have to be repeated occasionally until https://github.com/msys2/msys2/issues/62is fixed)
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
- Then synchronize new repository
pacboy update
This updates
msys2-runtime
and therefore will ask you to close the window (notjust exit the pacman process). Don't panic, simply close all currently open MSYS2 shells and MSYS2 programs. Double-check Task Manager and killpacman.exe
it's still running after the window is closed, because it can linger. Once all are closed, start a new terminal again.Then synchronize again(updating the non-core part of the packages):
pacboy update
- And finally install the Git/cURL packages:
pacboy sync git:x git-doc-html:x git-doc-man:x git-extra: curl:x
- Finally, check that everything went well by doing
git --version
in a MINGW64 shell and it should output something likegit version 2.14.1.windows.1
(or newer).
正确安装在 MSYS2 内部
请注意,Git for Windows 不正式支持此场景
(这是不受支持的原因是没有志愿者来支持这种情况。)
本指南假设您需要适用于 Windows 的 64 位 Git 版本。
Git for Windows 基于 MSYS2,可以将
git
包安装到现有的 MSYS2 安装中。这意味着如果你已经在你的计算机上使用 MSYS2,你可以在不运行完整安装程序或使用便携式版本的情况下使用 Git for Windows。但是请注意,采用这种方式有一些注意事项。Git for Windows 创建了一些
msys2-runtime
尚未发送到上游的补丁。(这是计划好的,但在问题#284 中确定它可能不会发生。)这意味着您必须为 Windows 安装 Git,msys2-runtime
以便在 MSYS2 中拥有一个完全可用的 git。这里要采取的步骤:
打开 MSYS2 终端。
编辑
/etc/pacman.conf
之前[mingw32]
(我机器上的第 71 行),添加git-for-windows
包存储库:
[git-for-windows] Server = https://wingit.blob.core.windows.net/x86-64
以及可选的相反架构的 MINGW -only 存储库(即 MINGW32 用于 64 位 SDK):
[git-for-windows-mingw32] Server = https://wingit.blob.core.windows.net/i686
- 授权签名密钥(此步骤可能需要偶尔重复,直到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
- 然后同步新的存储库
pacboy update
这会更新
msys2-runtime
,因此会要求您关闭窗口(而不仅仅是退出 pacman 进程)。不要惊慌,只需关闭所有当前打开的 MSYS2 shell 和 MSYS2 程序。仔细检查任务管理器并pacman.exe
在窗口关闭后杀死它仍在运行,因为它可以逗留。全部关闭后,再次启动新终端。然后再次同步(更新包的非核心部分):
pacboy update
- 最后安装 Git/cURL 包:
pacboy sync git:x git-doc-html:x git-doc-man:x git-extra: curl:x
- 最后,通过
git --version
在 MINGW64 shell 中执行检查是否一切正常,它应该输出类似git version 2.14.1.windows.1
(或更新)的内容。
回答by WeiHua Liu
Tested on Windows 10 x86_64 1909 10.0.18363.752
在 Windows 10 x86_64 1909 10.0.18363.752 上测试
Using regular Git for Windows.
在 Windows 上使用常规 Git。
- Install
msys2
(Version 20190524 is tested.) orGit for Windows SDK
. (Not fully tested, but it should work.) Both include PacMan and Git.
- 安装
msys2
(已测试版本 20190524。)或Git for Windows SDK
. (没有经过全面测试,但它应该可以工作。)两者都包括 PacMan 和 Git。
Using VFS for Git for Windows or Scalar for Git for Windows.
使用 VFS for Git for Windows 或 Scalar for Git for Windows。
Virtual Filesystem for Git (formerly GVFS) is recommended. Version 2.22 & 2.26 are tested. Scalar is NOT recommended, neither fully tested.
推荐用于 Git(以前称为 GVFS)的虚拟文件系统。版本 2.22 和 2.26 已测试。不推荐标量,也未经过全面测试。
Install
GVFS
andGit for Windows with GVFS patch
. Or installScalar for Git
andGit for Windows with Scalar patch
. NOT BOTHon the same machine. The default installation destination isC:\Program Files\Git
.Install msys2 x64 somewhere else. By default, it is in
C:\msys64
.Copy files and subfolders of msys2 (except /etc and git binaries. The msys2 comes without git from factory.) to git for windows VFS edition, and copy
/etc/pacman.d
and/etc/pacman.conf
in msys64 folder to Git folder, overwrite existing files. That will update msys2 and MinGW runtime to the latest version. For PacMan, the necessary files are/usr/bin/pac* ; /etc/pacman.conf ; /etc/pacman.d/ ; /var /usr/bin/msys* ;
.(Not fully tested.)Setup terminal applications. Run
C:\Program Files\Git\bin\bash.exe
will launch the bash of Git for Windows. RunC:\Program Files\Git\usr\bin\bash.exe
will launch bash of msys2. Configure the path of bash for terminal programs, such as Hyper Terminal. Since Git is in a system folder, terminal programs should be Run as administrator.Config $PATH the environmental variable for GVFS. Run this command in Git Bash.
export PATH=$PATH:/c/Program\ Files/GVFS
orexport PATH=$PATH:"/c/Program Files/GVFS"
. Or set environmental variables for GVFS in system property of the control panel. Re-login to take effect. Sometimes this configuration does not work, but PacMan can still run.Fix PacMan. Set executable permission for binaries. Fox example.
chmod +x /usr/bin/pacman ; pacman-key --init ; pacman-key --populate msys2 ; pacman-key --refresh-keys ; pacman --sync pacman --refresh --sysupgrade --sysupgrade --overwrite "*"
. Use the option--overwrite \*
because some packages were installed by Git for Windows instead of PacMan.
安装
GVFS
和Git for Windows with GVFS patch
. 或安装Scalar for Git
和Git for Windows with Scalar patch
。不是在同一台机器上。默认安装目标是C:\Program Files\Git
.在其他地方安装 msys2 x64。默认情况下,它在
C:\msys64
.复制文件和子文件夹msys2(除在/ etc和git的二进制文件。该msys2来自不从工厂饭桶。)与git的窗户VFS版,以及复制
/etc/pacman.d
和/etc/pacman.conf
在msys64文件夹Git的文件夹中,覆盖现有文件。这会将 msys2 和 MinGW 运行时更新到最新版本。对于 PacMan,必要的文件是/usr/bin/pac* ; /etc/pacman.conf ; /etc/pacman.d/ ; /var /usr/bin/msys* ;
.(未完全测试。)设置终端应用程序。Run
C:\Program Files\Git\bin\bash.exe
将启动 Windows 版 Git 的 bash。运行C:\Program Files\Git\usr\bin\bash.exe
将启动 msys2 的 bash。为终端程序配置bash的路径,例如超级终端。由于 Git 位于系统文件夹中,因此终端程序应以管理员身份运行。为 GVFS 配置 $PATH 环境变量。在 Git Bash 中运行此命令。
export PATH=$PATH:/c/Program\ Files/GVFS
或export PATH=$PATH:"/c/Program Files/GVFS"
。或者在控制面板的系统属性中为 GVFS 设置环境变量。重新登录生效。有时这种配置不起作用,但 PacMan 仍然可以运行。修复吃豆人。设置二进制文件的可执行权限。狐狸的例子。
chmod +x /usr/bin/pacman ; pacman-key --init ; pacman-key --populate msys2 ; pacman-key --refresh-keys ; pacman --sync pacman --refresh --sysupgrade --sysupgrade --overwrite "*"
. 使用该选项--overwrite \*
是因为有些软件包是由 Git for Windows 而不是 PacMan 安装的。