2

I'm trying to run gitk on Windows but the console gives me:

'gitk' is not recognized as an internal or external command,
operable program or batch file.

But then, I can do

> where gitk
C:\Program Files (x86)\Git\bin\gitk

How comes?

Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
Borek Bernard
  • 50,745
  • 59
  • 165
  • 240

1 Answers1

1

UPDATE: Stealing the OP's comment:

Thanks for a (lengthy) explanation, the easiest fix for me was to move from the old msysGit (1.9.5) version to the newer "Git for Windows" builds which has a proper Windows wrapper for gitk.


gitk, unlike most git commands, is a shell script that invokes Tcl.

If you examine the gitk executable file itself, its first few lines are:

#!/bin/sh
# Tcl ignores the next line -*- tcl -*- \
exec wish "$0" -- "$@"

(At least that's what it looks like on my Linux system; the Windows installer for gitk might change that.)

On a Unix-like system, that first line, known as a "shebang", tells the system to invoke /bin/sh to execute the file rather than executing it directly.

The third line executes the wish command, which executes the script as a Tcl script.

If you have Tcl installed on your Windows system, you should be able to run gitk as a Tcl script using something like this:

C:\> tclsh "C:\Program Files (x86)\Git\bin\gitk"

(Disclaimer: I have not tried this.)

You might also be able to change the command's name from gitk to gitk.tcl and set up a file association in Windows so it will be invoked correctly. (I'm a little surprised that the Windows git installer didn't do this for you.)

More information on running Tcl scripts on Windows can be found here.

And this question discusses invoking gitk on Windows from the context menu rather than from the command line.

Community
  • 1
  • 1
Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
  • 1
    Thanks for a (lengthy) explanation, the easiest fix for me was to move from the old msysGit (1.9.5) version to the newer "Git for Windows" builds which has a proper Windows wrapper for gitk. – Borek Bernard Aug 09 '15 at 17:47
  • I've stolen your comment and added it to my answer. – Keith Thompson Aug 09 '15 at 18:04