X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=git-wiki.txt;h=d5317044a29ec21655507aac36a8b065a724ce04;hb=36f3551fc27e21fbe4ef6276559feb61f50fb997;hp=57ba2841df3073409166f467b39f2fb573662915;hpb=9aa2facfd9f4ac3ca5a4c68a97533d0c0e56043e;p=git-wiki.git diff --git a/git-wiki.txt b/git-wiki.txt index 57ba284..d531704 100644 --- a/git-wiki.txt +++ b/git-wiki.txt @@ -49,11 +49,13 @@ many different languages. Download Russian translation from `GArik `Git Buch `_ (German). -Offline documentation ---------------------- +Builtin help +------------ -Git has builtin help: run ``git help $TOPIC``. For example, run -``git help git`` or ``git help help``. +Run ``git help $TOPIC``. For example, run ``git help git`` or +``git help help``. Run ``git help -a`` to list help topics for all +available commands; ``git help -g`` to list help guides, i.e. help topics +that aren't commands. Quick start @@ -756,6 +758,55 @@ See `WhatIsTheIndex Wiki. +Aliases +------- + +Recursive aliases +''''''''''''''''' + +Git doesn't allow recursive aliases. The expansion of an alias is +interpreted by git as a builtin command. I.e., in the following example +alias ``com`` doesn't work because there is no builtin command ``git +ci``:: + + [alias] + ci = commit + com = ci + +You can trick git by using shell. The following example works albeit a +bit slow:: + + [alias] + ci = commit + com = !git ci + + +Literal expansion +''''''''''''''''' + +Git interprets aliases literally. I.e., when expanding an alias git just +does simple textual substitution. That could be a surprise if an alias +is passed parameters on the command line. For example, the following +alias works without parameters -- it pushes configured branch(es) to all +configured remotes:: + + [alias] + push-to-all-remotes = !git remote | xargs -n1 git push + +But it doesn't work if a user wants to provide a list of branches to +push: the command ``git push-to-all-remotes master`` is expanded by git +as ``!git remote | xargs -n1 git push master`` which is certainly not +what the user wants -- remote's name must comes first, before branches. +This is a fix:: + + [alias] + push-to-all-remotes = !git remote | xargs -I% -n1 git push % + +Then the command ``git push-to-all-remotes master`` is expanded by git +as ``!git remote | xargs -I% -n1 git push % master``; xargs substitutes +``%`` with remote's name. + + Root ----