Usually, git aliases are confined to a single command:
git config --global alias.ci commit
So, instead of git commit
you could do git ci
But it seems you can insert a function in there as well:
git config --global alias.up-sub '!f() { cd $1 && git checkout master && git pull && git submodule update --init --recursive; }; f'
This allows you to call git up-sub some-submodule
The question is: how does it work? I haven't seen the !f()
syntax in any other context.
Looks like a regular shell function definition and invocation. Only the bang stands out, but a quick search through the git-config(1)
manual shows an explanation:
If the alias expansion is prefixed with an exclamation point, it will be treated as a shell command. For example, defining "alias.new = !gitk --all --not ORIG_HEAD", the invocation "git new" is equivalent to running the shell command "gitk --all --not ORIG_HEAD". Note that shell commands will be executed from the top-level directory of a repository, which may not necessarily be the current directory.
Without the bang, it would alias a git
subcommand.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments