Git 2.47
[git/gitster.git] / Documentation / config / alias.txt
blob2c5db0ad8428e8badf42d402e79d045a8128a117
1 alias.*::
2         Command aliases for the linkgit:git[1] command wrapper - e.g.
3         after defining `alias.last = cat-file commit HEAD`, the invocation
4         `git last` is equivalent to `git cat-file commit HEAD`. To avoid
5         confusion and troubles with script usage, aliases that
6         hide existing Git commands are ignored. Arguments are split by
7         spaces, the usual shell quoting and escaping are supported.
8         A quote pair or a backslash can be used to quote them.
10 Note that the first word of an alias does not necessarily have to be a
11 command. It can be a command-line option that will be passed into the
12 invocation of `git`. In particular, this is useful when used with `-c`
13 to pass in one-time configurations or `-p` to force pagination. For example,
14 `loud-rebase = -c commit.verbose=true rebase` can be defined such that
15 running `git loud-rebase` would be equivalent to
16 `git -c commit.verbose=true rebase`. Also, `ps = -p status` would be a
17 helpful alias since `git ps` would paginate the output of `git status`
18 where the original command does not.
20 If the alias expansion is prefixed with an exclamation point,
21 it will be treated as a shell command.  For example, defining
22 `alias.new = !gitk --all --not ORIG_HEAD`, the invocation
23 `git new` is equivalent to running the shell command
24 `gitk --all --not ORIG_HEAD`.  Note:
26 * Shell commands will be executed from the top-level directory of a
27   repository, which may not necessarily be the current directory.
28 * `GIT_PREFIX` is set as returned by running `git rev-parse --show-prefix`
29   from the original current directory. See linkgit:git-rev-parse[1].
30 * Shell command aliases always receive any extra arguments provided to
31   the Git command-line as positional arguments.
32 ** Care should be taken if your shell alias is a "one-liner" script
33    with multiple commands (e.g. in a pipeline), references multiple
34    arguments, or is otherwise not able to handle positional arguments
35    added at the end.  For example: `alias.cmd = "!echo $1 | grep $2"`
36    called as `git cmd 1 2` will be executed as 'echo $1 | grep $2
37    1 2', which is not what you want.
38 ** A convenient way to deal with this is to write your script
39    operations in an inline function that is then called with any
40    arguments from the command-line.  For example `alias.cmd = "!c() {
41    echo $1 | grep $2 ; }; c" will correctly execute the prior example.
42 ** Setting `GIT_TRACE=1` can help you debug the command being run for
43    your alias.