问题
I am using git as my revision control system. To do so, I installed msysGit to checkout my repositories on MSW. Now I want to compile my programs with MinGW and found this "problem" for me: When I install MinGW and MSYS via mingw-get I can compile my program, no problem. But I can not access git. When I use the Git Bash, I can work with git, but can not compile.
Is there any possibility to:
- install MinGW "into" Git Bash (because it already contains msys, didn't it?) OR
- to set "links" between both installations to make it work.
I would prefere the way I can keep both packages up to date more easily.
Thanks in advance :)
回答1:
How did you install Msysgit? Did you choose the third option in the screen where it asks for PATH setup?
(above screenshot from: http://ekkescorner.files.wordpress.com/2010/02/git-windows-msysgit-install-3.png.)
You have to choose the third option or even second might suffice.
Below is screenshot from my MingW
Anyway, it's all about setting proper path to the git.exe in msysgit, or am I missing something?
回答2:
You can add a symbolic link to git in MinGW, if you chose the second option.
So if your msysgit installation is in C:\Program Files (x86)\Git Open the MinGW shell and type:
cd /usr/bin
ln -s /c/Program\ Files\ \(x86\)/Git/bin/git git
This will create a symbolic link called git in MinGW's /usr/bin pointing to the msysgit installation. Then you can use the git command anywhere from the MinGW shell.
回答3:
You need to fix up the PATH so that you are running the external commands that match the msys or msysgit environment. Depending on how you installed these two shell environments one of them will be first in the PATH so regardless of which bash you are running you will be running external commands from the bin directory which is first in the PATH.
You can test this by running ls.exe from the different bash shells, I found one worked and one didn't but when I fixed up the PATH they both worked.
I tried to work out a clever script that would work for both but it is difficult as they both map their own bin directory to /bin. When I got sick of trying to work this out I created msys.sh and msysgit.sh with the line:
export PATH=/c/MinGW/msys/1.0/bin:/c/MinGW/bin:${PATH}
or
export PATH="/c/Program Files (x86)/Git/bin:${PATH}"
respectively. These files need to be sourced into the environment you are running. For example:
source ./msys.sh
You actually only need one script as one environment will work, but I also installed RubyDevKit which had the same problem so it seemed simpler to create a script for each environment.
回答4:
If you want the path change every time you start your git bash on windows. You need do the following steps:
- In windows run, type "git bash"
- Vim ~/.profile
- Add "export PATH=/c/MinGW/msys/1.0/bin:/c/MinGW/bin:${PATH}" to last line of the file.(The MinGW should locate in C:\MinGW)
- :wq, exist the vim.
- exit the git bash, and restart again
来源:https://stackoverflow.com/questions/5885393/using-msysgit-from-mingw-and-vice-versa