Is there an option to show the full command when using an alias?
Example:
$ git ci -m "initial commit"
Full command: git commit -m "initial commit"
...
$ git lg
Full command: git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
...
Aliases are very convenient, but I like to learn/be reminded what my alias actually do (most of my aliases are copied from the Internet)
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.
To create this alias, just run this command: git config --global alias.
Another option is the command ideas listed in the Git wiki section on Aliases wich gives, for the alias
section of .git/config
[alias]
aliases = !git config --get-regexp 'alias.*' | colrm 1 6 | sed 's/[ ]/ = /'
This then lists all your aliases as command lines.
As an example:
log-1 = "!sh -c 'echo \"Full command: git log --graph --decorate --pretty=oneline --abbrev-commit\"; git log --graph --decorate --pretty=oneline --abbrev-commit' -"
You call the shell and execute the given commands.
In your lg example, you would have to do a whole lot of escaping as you have quotes inside qoutes and characters that need to be escaped. I suggest you create your own pretty format and use that in the alias. Let;s assume we call your format mine. This is what you need to do:
git config --add pretty.mine "%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset"
and the alias would be
lg = "!sh -c 'echo \"Full command: git log --graph --pretty=mine --abbrev-commit --date=relative\"; git log --graph --pretty=mine --abbrev-commit --date=relative' -"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With