Using msysGit with Cygwin

If you use msysGit http://code.google.com/p/msysgit/ with Cygwin http://www.cygwin.com/, here are some hacks to make the two environments more interoperable, and to make Cygwin paths more interoperable with native Windows programs.

Paths

First, let's change the /cygdrive mount point in Cygwin so that drive-qualified paths are more like they are in msys, e.g. instead of /cygdrive/c/foo we want /c/foo.

In the Cygwin shell, do this:

mount -c /

In /etc/fstab change the cygdrive mountpoint as well:

none / cygdrive binary,posix=0,user 0 0

Now, open a cmd.exe window with Administrator privileges, and run the following:

mklink /D C:\c C:\

repeat for any other drives you want aliased this way.

The reason for this is so that cygwin paths such as /c/foo/bar work with native Windows programs as well.

Git Configuration

In Cygwin git, run this command:

git config --global core.autocrlf true

This is necessary if you want to run git commands on your msysGit clones, because msysGit defaults this option to on, otherwise you will make erroneous commits with the wrong line endings.

Occasionally you may need to convert a project to UNIX line endings. To do so use this procedure:

git config core.autocrlf false
rm .git/index
git checkout -f HEAD

In both Cygwin git and msysGit run the following:

git config --global core.filemode false

To ignore +x bits on files.

You will also need to run:

git config core.filemode false

in every project.


Last modified: 2017-1-8 (日) at 9:14 pm