my ~/.gitconfig is:
[alias] commit = "!sh commit.sh"
However, when I type git commit, script is not called.
Is it possible, or I have to use another alias name?
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.
Start a new branch. gitconfig file and add each alias under [alias], like so: Additionally, you can have repo-specific aliases. Just edit . git/config in the repo where you want to add the alias, and follow the same syntax.
Add git alias The simplest way to add a git alias is by running a command to add the alias to the git global configuration file. For example, running the command git config --global alias. hist "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short" will add the alias git hist .
It is NOT POSSIBLE
This is from my clone of git.git:
static int run_argv(int *argcp, const char ***argv) { int done_alias = 0; while (1) { /* See if it's an internal command */ handle_internal_command(*argcp, *argv); /* .. then try the external ones */ execv_dashed_external(*argv); /* It could be an alias -- this works around the insanity * of overriding "git log" with "git show" by having * alias.log = show */ if (done_alias || !handle_alias(argcp, argv)) break; done_alias = 1; } return done_alias; }
So its not possible. (handle_internal_command
calls exit
if it finds the command).
You could fix this in your sources by changing the order of the lines and making handle_alias
call exit
if it finds the alias.
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