Using msysGit from MinGW and vice versa
Asked Answered
Y

4

14

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 :)

Yodel answered 4/5, 2011 at 14:53 Comment(1)
related: https://mcmap.net/q/397347/-combining-mingw-and-gitSergeant
M
7

How did you install Msysgit? Did you choose the third option in the screen where it asks for PATH setup?

enter image description here

(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

enter image description here

Anyway, it's all about setting proper path to the git.exe in msysgit, or am I missing something?

Mortician answered 4/5, 2011 at 21:45 Comment(1)
I used the second option when installing. Just when I enter where git I get the git.cmd file. So I added the bin directoy manuelly to PATH and it works. Thanks :)Yodel
I
10

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.

Incapacitate answered 6/7, 2012 at 16:57 Comment(3)
Glad to see sanity return as apposed to the countless other hacks leaving not only the reader but the author amazed with: Wow it actually works. I keep thinking, symlinks anyone? What really baffles me though, why two msys environments to start of with?Joaquin
msysGit is a subset of msys but also includes additional utilities which may be required with git like ssh, curl and vi. It even gets worse if you also have RubyDevKit installed as you get another msys.Beefwitted
When I try this from my MinGW/MSYS prompt (msys-base 2013073200 - current as of 8 Mar 2015), the resulting symlink fails to invoke git.exe properly: error launching git: The filename or extension is too long. What does work, however, is to append to $PATH via ~/.profile; e.g., PATH="$PATH:/c/program files (x86)/git/cmd"Zoezoeller
M
7

How did you install Msysgit? Did you choose the third option in the screen where it asks for PATH setup?

enter image description here

(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

enter image description here

Anyway, it's all about setting proper path to the git.exe in msysgit, or am I missing something?

Mortician answered 4/5, 2011 at 21:45 Comment(1)
I used the second option when installing. Just when I enter where git I get the git.cmd file. So I added the bin directoy manuelly to PATH and it works. Thanks :)Yodel
B
1

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.

Beefwitted answered 7/8, 2014 at 2:44 Comment(0)
S
0

If you want the path change every time you start your git bash on windows. You need do the following steps:

  1. In windows run, type "git bash"
  2. Vim ~/.profile
  3. 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)
  4. :wq, exist the vim.
  5. exit the git bash, and restart again
Scenic answered 9/3, 2017 at 3:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.