结合 mingw 和 git
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5648330/
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
Combining mingw and git
提问by NickSoft
I have installation of MinGWin D:\mingw. I have Gitinstallation in C:\Program Files\git. I want to develop/compile using MinGW and use git for versioning.
我在 D:\mingw 中安装了MinGW。我的Git用C安装:\ Program Files文件\饭桶。我想使用 MinGW 开发/编译并使用 git 进行版本控制。
I guess I have to use correct paths but some paths are hardcoded. Like msys mount script calls /bin/msysmnt.exe
我想我必须使用正确的路径,但有些路径是硬编码的。像 msys 挂载脚本调用 /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
所以我有 2 个选项:1. 使用 git 的 shell(以便能够在提示符下向我显示分支) 2. 使用 mingw(msys) 的 shell - 获得正确的路径
Whichever I choose I must make the other functionality work under it.
无论我选择哪个,我都必须让其他功能在它之下工作。
采纳答案by rubenvb
Small update:Since the Git 2.x releases, Git for Windowsis based off of MSYS2and available in 32 and 64 bit binary form. It still is a fork, and not interchangeable with the real MSYS2.
小更新:自 Git 2.x 发布以来,Git for Windows基于MSYS2,并以 32 位和 64 位二进制形式提供。它仍然是一个叉子,不能与真正的 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).
您必须了解的一件事:msysgit(您正在使用的 git)是 msys 的一个分支,添加了 git 功能。msys shell 中包含许多 unix 工具(有关完整列表,请参阅 msysgit/bin 文件夹)。
It might be possible to add additional msys tools to the msysgit bin folder, but I would not risk my head on that.
可能可以向 msysgit bin 文件夹中添加其他 msys 工具,但我不会冒这个风险。
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.
鉴于此,我认为最好将您的工具链添加到 msysgit 路径(使用 bash 配置文件或 msysgit 树中的任何内容)并使用它。如果缺少特定实用程序,请从 MinGW-msys 树中添加它,并希望它可以正常工作。
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.
或者,只需使用 cmd.exe 中的 msys-git。从最近的版本开始,它运行良好(包括 git show、编辑提交消息等......)。为此,请将 /cmd 目录添加到 PATH,然后您就可以使用您想要的所有 git 命令。这就是我所做的,因为 msys 是一个拖累,但对于 git 在 Windows 上工作来说是必要的邪恶。
UPDATE: detailed instructions to add a directory to PATH under any kind of MSYS:
更新:在任何类型的 MSYS 下将目录添加到 PATH 的详细说明:
export PATH=/d/MinGW/bin:$PATH
or hackishly find /etc/profile and change this section
或hackishly 找到/etc/profile 并更改此部分
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.
没有更简洁的方法,因为 msys-git 人员禁用了 vanilla msys 中存在的 fstab 功能。
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:
我在C:\Program Files\Git\etc
名为bash_profile
. 这是文件的内容:
export PATH=$PATH:/d/mingw/bin:/d/mingw/msys/1.0/bin
make and gcc worked.
make 和 gcc 工作。
The bash_profile
does not come with msysgit so you won't overwrite it if you update.
在bash_profile
不附带msysgit所以如果你更新你不会覆盖它。
回答by Jon Davis
I put Git on the MinGW shell by opening c:\MinGW\msys\1.0\etc\profile (not in Notepad, there are no carriage returns) and adding:
我通过打开 c:\MinGW\msys\1.0\etc\profile(不在记事本中,没有回车)并添加:
export PATH=$PATH:/c/Program\ Files\ \(x86\)/Git/bin
On an x86 system this would be:
在 x86 系统上,这将是:
export PATH=$PATH:/c/Program\ Files/Git/bin
回答by plan9assembler
update:
更新:
now msys comes with git binary package.
现在 msys 带有 git 二进制包。
http://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/
http://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/
old answer:
旧答案:
If you are using latest mingw& portableGit, just drop git.exe(extract the file from portableGitXXX.7z) into C:\MinGW\msys\1.0\bin\
如果使用的是最新的MinGW&portableGit,只是下降git.exe(摘自portableGitXXX.7z文件)到C:\ MinGW的\ MSYS \ 1.0 \ BIN \
回答by hanetzer
Use msys2. Its msys with a decent package manager (pacman) and build system (makepkg), ported from arch linux. I've got one shell with all my devtools and git and such al
使用 msys2。它的 msys 带有一个不错的包管理器(pacman)和构建系统(makepkg),从 arch linux 移植过来。我有一个外壳,里面有我所有的开发工具和 git 等等