Table of Contents

git on Windows

As of this writing, the official git distribution for Windows is the cygwin version. However, Msysgit is also popular, but Msysgit and cygwin's git won't play nice together without a few tweaks. To avoid any tweaks, you can use cygwin's git for all real work and just have Msysgit for the easy icon display to identify versioning changes.

git gui and gitk on cygwin

Ever since day one with git, I've been using the two most powerful front-ends (git gui and gitk) along with the command line. No matter how fast anyone thinks they are with the command line, these two tools do several things faster and more efficiently, and any other gui I've tested is certainly a compromise. Much to my chagrin, early in 2012, the maintainers of the tcl/tk package of cygwin pushed out a version of this toolkit that requires an X server. Prior to this, you could easily run cygwin with a good shell such as rxvt, and kick off the two most powerful and utilized gui's for git using the native windows calls for drawing (fast, low overhead). Now you are being forced to start a complete X server to get either of these to work. Command line git will work fine, but not the gui's. I understand and appreciate the efforts of the free software developers, but this one really stinks.

Anyway, I've come up with a solution that works well and does NOT use an X server. The description of this may sound like a hassle or kludge, but rest assured it works well and is fast. My solution is to install msysgit and use aliases to kick off the gui's. I already had msysgit because of TortoiseGit, and I already used aliases anyway because I launch the programs maybe 25 to 100 times every day. Why not just use msysgit? Because I need the full suite of unix tools provided by cygwin; it is only the tcl/tk stuff that is causing me issues right now.

So, just set up cygwin and git as normal, then set up msysgit. Edit your .profile or .bash_profile to have aliases similar to these (I've even included examples to launch Tortoise clients here):

# an update early in 2012 to cygwin's tcl/tk package forced everything using
# tcl/tk to be ran on an X windows server, so these gui aliases are now
# kickstarting TortoiseGit and msysgit programs instead
# Cygwin git
#alias gg='git gui&'
#alias gk='gitk&'
 
# Cygwin git / msysgit hybrid (checks if x server is available)
alias gg="([ \"\$(ps|grep XWin)\" ] && git gui || mgg)&"
alias gk="([ \"\$(ps|grep XWin)\" ] && gitk || mgk)&"
alias gka="([ \"\$(ps|grep XWin)\" ] && gitk || mgk --all)&"
 
#TortoiseGit
alias tgg="/cygdrive/c/Program\ Files/TortoiseGit/bin/TortoiseProc.exe /command:repostatus /path:\"\`cygpath -m -a .\`\" &"
alias tgk="/cygdrive/c/Program\ Files/TortoiseGit/bin/TortoiseProc.exe /command:log /path:\"\`cygpath -m -a .\`\" &"
 
#msysgit
alias mgg="/cygdrive/c/Program\ Files\ \(x86\)/Git/bin/git gui"
alias mgk="/cygdrive/c/Program\ Files\ \(x86\)/Git/bin/wish.exe \"C:/Program Files (x86)/Git/bin/gitk\""

I'm also eager to see what the msysgit folks decide to do with tk; hopefully they leave it alone :)

More Information

TortoiseGit

TortoiseGIT is also very popular since TortoiseSVN is considered one of the best clients/addons available for Windows. TortoiseGIT uses msysgit's binary behind the scenes.

I've had the best luck with TortoiseGIT by setting the following:

gitshare

It is advisable to set up common paths that both cygwin git and msysgit (and tortoisegit) can clone/pull/push to and from. The best way I've found is to either use ssh entirely (although I haven't tried ssh over tortoise yet), or to make mount points. Mount points involve 3 places:

  1. in cygwin, we create a mount point by this command in our “~/.profile”. It also is set with noacl so permission errors won't become a problem
    mount -f -o binary,posix=0,noacl //unc/or/cygwin/file/path/git /gitshare
  2. in windows (dos shell), we create a symbolic link at the root of C. This will allow us to put the exact url that we used in cygwin, which in this case is /gitshare/path/to/repo.git (windows/msysgit/tortoisegit will resolve /gitshare to c:\gitshare)
    open a dos shell by running as administrator (only administrator can run mklink command)
    c:
    cd \
    mklink /D gitshare x:\path\to\git\repo
  3. lastly, we set up a link in the same way so msysgit can find it when using a bash shell in msysgit
    c:
    cd "Program Files (x86)\Git" (or wherever you installed msysgit)
    mklink /D gitshare x:\path\to\git\repo

filemode

If you do try to use cygwin git and msysgit together, you may notice the msysgit will identify all files as changed when a project is cloned via cygwin git. This is because cygwin git sets core.filemode = true for each cloned repository. It doesn't even matter if you have filemode = false in your ~/.gitconfig, it will set it based on detected file system capability.

To fix this, you can either remember to set filemode = false in each repo's .git/config file, or use msysgit to clone the project. To edit many .git/config files in a folder containing many working copies, you can use commands like this:

vi `find . -maxdepth 3 -name config`

An easy way to check the status of your configs is to use my gitr script and pipe it with grep like this:

gitr showconfig|grep -E 'showing|filemode'