Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I debug a git alias?

Tags:

git

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

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

like image 464
Tom Hale Avatar asked Sep 13 '16 10:09

Tom Hale


People also ask

How do I debug git?

How it works? git bisect start: It start up the git bisect wizard. git bisect bad “version”: It let the git bisect wizard know of a bad commit. git bisect good “version”: It let the git bisect wizard know of a good commit.

Where are git aliases stored?

Your git aliases are often stored per your user's configuration at ~/. gitconfig . You can also manually set aliases using, for example, the command git config alias. s 'status -s' .

What is a git alias?

Git aliases are a powerful workflow tool that create shortcuts to frequently used Git commands. Using Git aliases will make you a faster and more efficient developer. Aliases can be used to wrap a sequence of Git commands into new faux Git command.


1 Answers

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
like image 154
Tom Hale Avatar answered Nov 04 '22 02:11

Tom Hale