Git on Windows with msysGit

Sunday, 20 September 2009 by alexandrul
Permalink

The article is based on Install MSysGit wiki page from the msysGit website, and you could also read Updating MSysGit.

For best results use one of the following Git versions:

  • Git 1.7.0.1 - recommended
  • Git 1.6.6.2
  • Git 1.6.5.8
  • Git 1.6.4.4

Requirements

Setting up Git

First unpack msysGit installer to your desired location (7-Zip works just fine). In my case, the location is K:\dev\tools\msysGit. Also, this folder is the root folder inside the msysGit shell, and would be the reference for the rest of the tutorial.

In the K:\dev\tools\msysGit\git folder you will find the Git source code provided with the installer. Delete all the files and folders inside it, and then unpack in the same folder the source code of your desired git version.

Final step would be running K:\dev\tools\msysGit\msys.bat, which will compile and install git, and leave you to a shell prompt.

At this prompt, you could add a desktop shortcut to msysGit shell:

/share/msysGit/add-shortcut.tcl d

The other possible actions are:

Usage: K:/dev/tools/msysGit/share/msysGit/add-shortcut.tcl [option]
Options:
	
  QuickLaunch         create a QuickLaunch icon
  Desktop             create an icon on the Desktop
  StartMenu           create an icon in your start menu
  StartMenu2          create an icon in start menu's Programs>msysGit
  AllUsersStartMenu   create an icon in All Users' start menu
  AllUsersStartMenu2  create an icon in All Users' start menu's Programs>msysGit
  EnableQuickEdit     enable the QuickEdit mode in the console
	
Short options are q, d, s, s2, a and a2.

As an optional step, you could add another cmd file in K:\dev\tools\msysGit\cmd folder (mine is called bash.cmd), which contains the command used for the msysGit desktop shortcut created before, allowing you to start the shell from any command prompt:

@K:\dev\tools\msysGit\bin\sh.exe --login -i

Free some space

In the /git folder you can clean the compiled binaries, since they were copied in the required locations:

cd /git
make clean

Another step would be to strip the binaries from /bin and /libexec/git-core/:

/mingw/bin/strip.exe /bin/*.exe /libexec/git-core/*.exe

All the commands in this section must be typed in a msysGit shell.

Updated html documentation

Since html documentation can’t be build due to missing asciidoc, you must download git-htmldocs-1.7.0.1.tar.gz and unpack the content in the K:\dev\tools\msysGit\doc\git\html folder, after deleting the previous content.

Git Gui, gitk, TortoiseGit and Git Extensions

In order to use all the clients from both msysGit shell and cmd.exe, you must copy all files and folders from /mingw/lib into /lib, and also from /mingw/bin into /bin.

SSH connections

If you want to use plink.exe for ssh connections, you have to add the private key to pageant, and define an environment variable with the full path of the plink.exe, like:

GIT_SSH=K:\dev\tools\PuTTY\plink.exe

In case of plink errors, you could try to include the login name in the git URLs, or connect first with putty.exe in order to add the host to the trusted list.

Cmd.exe integration

If you want to use git commands inside any command prompt, you need to add the /cmd folder of your msysGit installation to your path, in my case this would be K:\dev\tools\msysGit\cmd

For branch/diff/status color output, run the following command:

git config --global color.ui auto

and then set two environment variables:

LESS=FRSX
TERM=cygwin

Other settings

In order to disable the commit line endings transformation, you could run:

git config --global core.autocrlf false

8 comments

  1. Adam D. Says:
    Tuesday, September 1, 2009 - 03:54:07

    git config –global core.autocrlf false

    is a must UNLESS you’re doing x-platform dev.

  2. Pavlosius Says:
    Monday, September 21, 2009 - 06:14:45

    Сайт очень качественный. Вам награду бы за него или просто орден почета. :)

  3. Richard Pöttler Says:
    Monday, October 12, 2009 - 18:10:10

    I haven’t read the full post yet, but instead of useing “git config” and all this color.{branch,diff,status} stuff, you could say “color.ui”. I also wouldn’t set the color settings to “always” becaues I ran into troubles when I tried to use guilt or the output of those commands in scripts. A better way ist to set color settings to “auto”

    bye
    richi

  4. alexandrul Says:
    Monday, October 12, 2009 - 20:37:25

    You’re right, updated.

  5. Vladimir Sizikov Says:
    Sunday, October 18, 2009 - 14:23:29

    Terrific info, thanks! Saved me quite some time to figure this all out.

  6. SEO Services Says:
    Wednesday, December 30, 2009 - 10:10:11

    The detail information about InstallMSysGit and UpdatingMSysGit proved to be a great help for me.I am very grateful to you.

  7. Corporate Events Venues News Says:
    Thursday, January 28, 2010 - 13:44:56

    Beautiful post but you have to update your post now…good work man thanks..

  8. Teeth Whitening Melbourne Says:
    Monday, February 1, 2010 - 13:40:28

    I have my settings on auto update windows XP home SP2. An update from 8 weeks ago keeps showing up, after you click to install it is still there! It is not a new update same old one.

Add comment

Fill out the form below to add your own comments

User data





Add your comment