Around a week ago, I found out about git aliases. And at that moment, I sold my soul to the scripting gods (willingly) to get… a customized git!
A fair tradeoff, if you ask me.
See my full gist here.
The Basics
Aliases can be configured using git config
like so:
1
$ git config --global alias.<name> <command>
Which allows you to run a git command:
1
2
$ git <name> <args>
git <command> <args>
But if you prefix <command>
with a !
, then it runs in the shell directly:
1
2
3
$ git config --global alias.<name> '!<command>'
$ git <name> <args>
<command> <args>
And if you also wrap it in a function (e.g. f
), you can gain full control over the arguments:
1
2
3
$ git config --global alias.<name> '!f() { <command>; }; f'
$ git <name> <args>
f() { <command>; }; f <args>