Combining mingw and git
Asked Answered
S

5

40

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.

Saunder answered 13/4, 2011 at 11:20 Comment(1)
related: #5885893Flexuosity
G
28

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.

Goutweed answered 13/4, 2011 at 11:26 Comment(8)
first suggestion - I know in general what needs to happen. I need the details. "add toolchain to msysgit path" does not say it allSaunder
that helped a lot. I've added mingw/bin and msys/1.0/bin to path and it worked. however I miss the mount functionality. my files are under /d/mingw/msys/1.0/home/.... is there an easy way to workaround this. maybe overwrite some files from msysgit with files from original msys?Saunder
If you're missing msys features, try doing the reverse: adding the msys-git/bin path to your MinGW-msys install (in the same fashion). With a bit of luck that should work as well. To add the toolchain to MinGW-msys in the designed fashion, run sh /postinstall/pi.sh and follow instructions (but you knew this of course ;))Goutweed
well msysgit is a bit complex. it sets defines a lot of shell functions. one advantage is to show the current branch in bash prompt... but I'll try that too. maybe copying git profile over msys'Saunder
@NickSoft: that'll get you a lot of the bash aliases. If you don't mind me asking, why do you need the bash shell for git explicitely? Why not use the provided cmd wrapper?Goutweed
bash is a shell, cmd is not. aliases, scripting - everything is easier and I can use my bash scripts from linux.Saunder
@NickSoft: OK, I guess I must be simple in that regard. All I do is copying, svn, git, mkdir, rmdir. To each his own :)Goutweed
well, most of the time I do only these, but still hitting tab works better in bash. I also like to find files and do things with them : find <options>|while read f; do echo $f; rm $f; mv $f; grep xxx $f ... ; doneSaunder
U
16

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:

export PATH=$PATH:/c/Program\ Files\ \(x86\)/Git/bin

On an x86 system this would be:

export PATH=$PATH:/c/Program\ Files/Git/bin
Ulund answered 23/5, 2011 at 6:52 Comment(0)
M
7

Use msys2.

It's 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.

Muttonchops answered 9/6, 2014 at 0:26 Comment(1)
Perhaps the addition of the actual pacman command would have helped make this answer even better.Fanchan
M
7

As of today, just pacman -S git in msys2 mingw64 shell installs git

Meany answered 4/9, 2020 at 5:41 Comment(2)
This worked for me, thanks! As of today MSYS2 v 20210228 installs git version 2.31.1 using this methodTavis
This should be the preferred way to go. Git is just a small addition to the tools that are already available for msys2/mingw64. BTW, you should also run pacman -S man (or use pacman -S git man instead).Fanchan
M
6

update:

now msys comes with git binary package.

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\

Malnutrition answered 9/8, 2011 at 5:16 Comment(3)
git for windows is more than just the git executable. it has bash prompt, case insensitive bash autocompletion for files and directories, git gui ... etc. It's also possible that git is using some dll libraries that are not compatibe with my mingw versions.Saunder
@Saunder At this point in time, GitHub's GUI for Windows seems to be better (or at least more intuitive) than the GUI that comes with Git itself. On the other hand, it also hides some of the features of Git and requires you to open up a shell when anything out of the ordinary happens or is required (though it's usually good about telling you that and allowing you to easily open whatever shell you have it configured to run command-line Git). The current inputrc.default that comes with Msys also has case-insensitive autocomplete enabled, but I'm not sure if it did ~3 years ago.Glue
Interesting... I just downloaded MinGW to perform some cross-platofrm testing... No Git out of the box even though MSYS is installed. And mingw-get install git results in mingw-get.exe: *** ERROR *** git: unknown package.Calculation

© 2022 - 2024 — McMap. All rights reserved.