How do I expand a built in Git command with an alias? -
when answering "git pull hook script executes locally", stumbled upon use-case alias built-in git command such pull
or push
extension. how do that?
first thought was:
[alias] push = "!echo -n \"really push? [y/n]\";read -s -n 1 really;if [[ $really == \"y\" ]];then git push; else echo \"aborting\"; fi"
this works fine long don't name alias push
(for example qp
or that). call push
, it's somehow ignored.
is there git way expand built in git command alias or have set alias in .bashrc
?
short answer: you can't.
git disallows explicitly prevent confusion , shadowing might affect invocation of git commands (in scripts, etc.). see git-config manpage.
alias.*
command aliases git(1) command wrapper - e.g. after defining "alias.last = cat-file commit head", invocation "git last" equivalent "git cat-file commit head". avoid confusion , troubles script usage, aliases hide existing git commands ignored. arguments split spaces, usual shell quoting , escaping supported. quote pair , backslash can used quote them.
you could, noted, name alias else , use instead, or in bash
. however, note multiword aliases in bash not possible, can't have alias "git push". instead you'll need use function -- see "bash: spaces in alias name" on superuser hints (you can adopt wholesale).
Comments
Post a Comment