Syntax for Git aliases with multiple commands

后端 未结 4 896
滥情空心
滥情空心 2020-12-08 13:42

I want to create a Git alias to perform multiple commands, but I cant find documentation on how this is done.

  1. What is the syntax for Git aliases with multiple
4条回答
  •  既然无缘
    2020-12-08 14:09

    $ git config alias.q '!echo a; echo b'
    
    $ git q
    

    Output:

    a
    b
    

    I think this is (rudimentarily) documented in man git-config under alias.*

    Note that git commands should include git, unlike in normal aliases. It is caused by fact that it is treated as a shell command, not as a git command (see manpage quoted in the question). For example to chain

    git init
    

    and

    git commit --allow-empty -m "empty initial commit"
    

    it is necessary to create

    "!git init; git commit --allow-empty -m \"empty initial commit\""
    

    alias.

提交回复
热议问题