What are the differences between msys/git and git-for-windows/mingw-w64-x86_64-git?
Asked Answered
Q

2

49

To be able to run the test scripts for my cross-platform application also on Windows, I installed MSYS2 and used pacman to install any packages my test scripts rely on.

Since MSYS2 provides a port of git (msys/git), I think there is no need to install Git for Windows as well. But what are the differences between the git version provided in the MSYS2 repository and the one provided by Git for Windows?

I noticed these differences so far:

  1. msys/git will fail when running pip freeze on a virtualenv where a Python package from a git clone is installed in develop mode:

    FileNotFoundError: [WinError 3] The system cannot find the path specified: '/c/users/user/documents/project/.git\\..'
    

    git-for-windows/mingw-w64-x86_64-git doesn't fail, so there are at least some differences with respect to path handling.

  2. Git for Windows's gitk and git gui work out of the box. There's no need to set the GIT_GUI_LIB_DIR environment variable as described here.

It seems git from the Git for Windows repository offers the best experience at this point.

P.S. You can install Git for Windows's git in MSYS2 by adding the following to /etc/pacman.conf, above the [mingw32], [mingw64] and [msys] entries. But it might be a better idea to install the Git for Windows SDK instead, which is basically a special edition of MSYS2 including Git for Windows. Otherwise, the procedure below (and more) is also described here.

[git-for-windows]
Server = https://dl.bintray.com/$repo/pacman/$arch

[git-for-windows-mingw32]
Server = https://dl.bintray.com/git-for-windows/pacman/i686

After this (and perhaps a pacman -Sy), you can install the Git for Windows's git:

pacman -S mingw-w64-x86_64-git

I suppose there's no reason not to install Git for Windows's git in MSYS2?

EDIT The Git for Windows (un)installer left behind C:\ProgramData\Git\config. This points git at the wrong location for the SSL certificates. You can remove C:\ProgramData\Git\config to fix this.

Quach answered 26/10, 2016 at 12:33 Comment(9)
I've had trouble using MSYS2's git in e.g. QtCreator, where the interaction between git and the IDE went wrong, but Git For Windows worked fine. That was some time ago though.Eleonoreeleoptene
It would be nice, if the answer could also detail the difference between MSYS2+git and git for windows. As far as I see, the advantage of MSYS2+git is that you have the whole MSYS2 ecosystem (including pacman) and the advantage of Git for Windows is that you get the shell extension and the graphical tools. Is there a possibility to combine those advantages?Djerba
@FlorianKusche both the msys/git and git-for-windows/mingw-w64-x86_64-git packages include the graphical tools (gitk and git gui). They are broken out-of-the-box in msys/git though, as mentioned in the question.Quach
When i add the repositories to pacman.conf and run pacman -Sy i'm getting error signature from "Johannes Schindelin <[email protected]>" is unknown trust, invalid or corrupted database of PGP signatures.Arabel
@Arabel I've seen this before and I'm not sure why this happens, but you can ignore this error by setting SigLevel = Optional TrustAll in the [git-for-windows] section in /etc/pacman.conf. Though from a security standpoint, that's probably a big no-no.Quach
I found this guide how to install Git for Windows's git in MSYS2 properly, and it also explains how to solve the problem with signature.Arabel
When I timed git clone of a large repository in Git for Windows versus Git in Msys2 the latter was actually faster. Can anybody confirm this?Girdle
"I suppose there's no reason not to install Git for Windows's git in MSYS2?." Well actually there is. Git for Windows fiddles with your environment, for example it forces inheriting Msys PATH from Windows PATH and sets HOME to C:\Users\user instead of the standard MsysInstallationPath\home\user, and many other things that may be undesired for some people.Arabel
msys2 can use C:\Users\user for HOME path too. Just set the env MSYS2_PATH_TYPE=inheritTwitty
M
16

msys/git is linked against a dynamic library provided by MSYS2 to provide POSIX-to-Windows compatibility (POSIX emulation) in a manner similar to how cygwin does (MSYS2 is forked from cygwin), thus it requires the MSYS2 environment to be present to run.

git-for-windows/mingw-w64-x86_64-git on the other hand, is compiled using the MinGW compiler, which performs the translation to native Windows calls at compile time, which results in a much faster binary compared to the emulation approach, and does only require native Windows libraries to run.

From The difference between MSYS2 and MinGW:

The POSIX emulation layer of MSYS2 binaries is convenient, but comes at a cost: Typically, MSYS2 programs are noticably slower than their MinGW counterparts (if there are such counterparts). As a consequence, the Git for Windows project tries to provide as many components as possible as MinGW binaries.

See also: How does MSYS2 differ from Cygwin?

Millet answered 2/11, 2017 at 15:5 Comment(1)
So as a rule of thumb, always prefer mingw compiled binaries, since they are native without the need of a POSIX compatibility layer. Fun fact, if you install the Git for Windows SDK winget install Git.SDK you get both, Git for Windows and the MSYS2 environment.Cotterell
P
3

git-for-windows/git issue 2688 adds a more recent (2020) perspective, from the maintainer of Git for Windows Johannes Schindelin:

The purpose of Git for Windows is really to bring Git to Windows.

While that implies that we have to ship quite a few Unix-like tools, it does not mean that we will include such tools unless they are needed for Git's own operations, or at least for historical reasons (needs of active contributors are sometimes a factor in deciding whether to include a tool or not).

Having said that, what you really are looking for is MSYS2.
Git for Windows leverages MSYS2 and ships with a subset of its files. MSYS2 even sports a package management system called "pacman" to install more tools (including Git...).

The documentation is "Install inside MSYS2 proper" as noted in the question, but it has recently changed, since Pacboy is removed from the base installation.

So it needs to be added back with:

# pacman -Fy
:: Synchronizing package databases...
[...]
# pacman -F pacboy.exe
# pacman -F pacboy
msys/pactoys-git r2.07ca37f-1 (base base-devel)
    usr/bin/pacboy
    usr/share/bash-completion/completions/pacboy

Then:

Copying /var/lib/pacman/local files over from my msys2 installation into git-bash's, I was able to install tmux (as I planned/showed in OP), and it is working fine for me.

So, having /var/lib/pacman/local files is all it take for msys2 and pacman to work within git-bash (I meant git-for-windows).


To add to this, Git 2.40 (Q1 2023) explicitly removes support for MSys, which now lags way behind MSys2.

See commit 2987407, commit c0b5045 (02 Feb 2023) by Harshil-Jani (Harshil-Jani).
(Merged by Junio C Hamano -- gitster -- in commit 4158b92, 09 Feb 2023)

mingw: remove msysGit/MSYS1 support

Signed-off-by: Harshil-Jani
Acked-by: Johannes Schindelin

MSys has long fallen behind MSYS2 in features like Unicode or x86_64 support or even security bug fixes, and is therefore no longer used by anyone in the Git developer community.

The Git for Windows project itself started switching from MSys to MSYS2 early in 2015, i.e.
about eight years ago.

Let's drop supporting MSys as a development platform.

Building with MSys is no longer supported
Plinth answered 2/7, 2020 at 6:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.