From Git SCM Wiki
Revision as of 16:21, 23 February 2010 by Dscho (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



Due to certain limitations of Windows (such as command line length), Git for Windows has more issues than other platforms. This is especially bad when the window just flashes (i.e. opens and closes right away) without giving the user a hint as to what happened.

This page tries to help debugging such issues.

Show back traces

If you define the procedure backTrace as follows, you can call it anywhere to see in which order functions were called to get here (where "here" means wherever you input a call to the procedure):

proc backTrace {} {
       set level [info level]

       for {set i 1} {$i<$level} {incr i} {
               puts "$i: [info level -$i]"

Of course, on Windows you might want to call console show somewhere before, otherwise you will not see anything :-)

Git Gui specific

A tip to debug git gui: Add

  console show

right after exec wish in $GITINSTALLATIONROOT/libexec/git-core/git-gui.tcl or in /git/git-gui/ If you do it in the latter file do not forget to make install from inside /git/git-gui. This opens a tcl console whenever you start git gui and you can interact with the full tcl/tk power during runtime. You can adapt this technique to debug gitk.

There is a trace feature build into git gui you can enable it from the tcl console with set _trace 1 or pass the commandline option --trace when starting git-gui.

Basic hints

When you have problems with gitk or git gui, the first thing to do is to call them from Git Bash or Git Cmd, as the error messages and warnings are printed to the console which you would not see otherwise.

Showing execution traces

Since Tcl/Tk 8.4, there is a trace option, which you can use in combination with the fact that in Tcl, you can override the proc operator, which defines functions (this tip comes from the Tcl/Tk Wiki):

rename proc _proc
_proc proc {name arglist body} {
    uplevel 1 [list _proc $name $arglist $body]
    uplevel 1 [list trace add execution $name enterstep [list ::proc_start $name]]
_proc proc_start {name command op} {
    puts "$name >> $command"

Showing variable assignments

As with execution traces, you can also override the set operator, which sets variables (this tip comes also from the Tcl/Tk Wiki):

rename set _set
proc set {var args} {
    puts [list set $var $args]
    uplevel _set $var $args
Personal tools