Tom Hale
Tom Hale

Reputation: 46745

How can I debug a git alias?

Debugging git aliases with shell commands and quoting can be difficult.

How can I see what git is executing for a given alias?

Upvotes: 8

Views: 949

Answers (1)

Tom Hale
Tom Hale

Reputation: 46745

In your .gitconfig, add the following:

debug = !GIT_TRACE=1 git 

Then you can run git debug <aliasname>, for example:

$ git debug s
17:34:48.611406 git.c:563               trace: exec: 'git-s'
17:34:48.611696 run-command.c:336       trace: run_command: 'git-s'
17:34:48.613262 git.c:286               trace: alias expansion: s => 'status' '--short'
17:34:48.613338 git.c:563               trace: exec: 'git-status' '--short'
17:34:48.613350 run-command.c:336       trace: run_command: 'git-status' '--short'
17:34:48.615319 git.c:350               trace: built-in: git 'status' '--short'
 M app/models/user.rb
 M test/integration/users_edit_test.rb
?? html

Upvotes: 12

Related Questions