将mingw和git结合在一起 [英] Combining mingw and git
问题描述
我在D:\明天安装了 MinGW 。我在C:\ Program Files \ git中安装了 Git 。我想用MinGW进行开发/编译,并使用git进行版本控制。
我想我必须使用正确的路径,但有些路径是硬编码的。像msys mount script调用/bin/msysmnt.exe所以我有2个选项:
1.使用git的shell(能够显示我的分支提示)
2.使用mingw(msys)的shell - 拥有正确的路径
无论选择哪一个,我都必须使其他功能在其下工作。 / p>
小更新:自从Git 2.x发布以来, Git for Windows 是基于 MSYS2 ,并提供32位和64位二进制格式。它仍然是一个分叉,不能与真正的MSYS2互换。
你必须明白一点:msysgit(git你正在使用)是添加git功能的msys的一个分支。 msys shell中包含了许多unix工具(完整列表请参见msysgit / bin文件夹)。
也许可以添加其他msys工具msysgit bin文件夹,但我不会为此冒险。
鉴于此,我认为最好将工具链添加到msysgit路径中(使用bash配置文件或任何在msysgit树),并使用它。如果缺少特定的实用程序,请从MinGW-msys树中添加它,并希望它可以正常工作。
或者,只需使用cmd.exe中的msys-git即可。由于最近的版本,它工作得很好(包括git show,编辑提交消息等)。为此,请将/ cmd目录添加到PATH,并且可以使用所有您需要的git命令。这就是我所做的事情,因为msys是一种拖拽,但是git在Windows上工作的必要的邪恶。
更新:在任何目录下向PATH添加目录的详细说明类型的MSYS:
export PATH = / d / MinGW / bin:$ PATH
或骇人地找到/ etc / profile并更改此部分
if [$ MSYSTEM == MINGW32];然后
export PATH =。:/ usr / local / bin:/ mingw / bin:/ bin:$ PATH
else
export PATH =。:/ usr / local / bin :/ bin:/ mingw / bin:$ PATH
fi
to:
if [$ MSYSTEM == MINGW32];然后
export PATH =。:/ usr / local / bin:/ d / MinGW / bin:/ bin:$ PATH
else
export PATH =。:/ usr / local / bin:/ bin:/ mingw / bin:$ PATH
fi
没有更干净的方式,因为msys-git的用户禁用了vanilla msys中的fstab功能。
Nick的更新(我做过的工作):
我在 C:\ Program Files \Git\etc
中创建了一个名为 bash_profile
。这是文件的内容:
export PATH = $ PATH:/ d / mingw / bin:/ d / mingw / msys / 1.0 / bin
make和gcc都可以工作。
bash_profile
不附带msysgit,因此如果您更新,则不会覆盖它。
I have installation of MinGW in D:\mingw. I have Git installation in C:\Program Files\git. I want to develop/compile using MinGW and use git for versioning.
I guess I have to use correct paths but some paths are hardcoded. Like msys mount script calls /bin/msysmnt.exe
So I have 2 options: 1. use git's shell (to be able to show me branch at prompt) 2. use mingw(msys)'s shell - to have correct paths
Whichever I choose I must make the other functionality work under it.
Small update: Since the Git 2.x releases, Git for Windows is based off of MSYS2 and available in 32 and 64 bit binary form. It still is a fork, and not interchangeable with the real MSYS2.
One thing you must understand: msysgit (the git you are using) is a fork of msys with added git functionality. A lot of unix tools are included in the msys shell (for a full list, see the msysgit/bin folder).
It might be possible to add additional msys tools to the msysgit bin folder, but I would not risk my head on that.
In light of this, I think it would be optimal to just add your toolchain to the msysgit path (using the bash profile file or whatever in the msysgit tree) and just use that. If a particular utility is missing, add it from the MinGW-msys tree and hope it works OK.
Alternatively, just use msys-git from cmd.exe. Since recent versions, it works very well (including git show, editing commit messages etc...). To do that, add the /cmd directory to PATH, and you can use all the git commands you want. This is what I do, as msys is a drag, but a necessary evil for git to work on Windows.
UPDATE: detailed instructions to add a directory to PATH under any kind of MSYS:
export PATH=/d/MinGW/bin:$PATH
or hackishly find /etc/profile and change this section
if [ $MSYSTEM == MINGW32 ]; then
export PATH=".:/usr/local/bin:/mingw/bin:/bin:$PATH"
else
export PATH=".:/usr/local/bin:/bin:/mingw/bin:$PATH"
fi
to:
if [ $MSYSTEM == MINGW32 ]; then
export PATH=".:/usr/local/bin:/d/MinGW/bin:/bin:$PATH"
else
export PATH=".:/usr/local/bin:/bin:/mingw/bin:$PATH"
fi
There is no cleaner way because the msys-git people disabled the fstab functionality present in vanilla msys.
Update from Nick (what I did to make it work):
I created file in C:\Program Files\Git\etc
called bash_profile
. This is the contents of the file:
export PATH=$PATH:/d/mingw/bin:/d/mingw/msys/1.0/bin
make and gcc worked.
The bash_profile
does not come with msysgit so you won't overwrite it if you update.
这篇关于将mingw和git结合在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!