NickSoft NickSoft - 6 months ago 48
Bash Question

Combining mingw and git

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.

Answer

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.