Git 别名脚本将所有参数视为一个字符串

问题描述 投票:0回答:1

目前,我有以下别名

[alias]
    comment = commit -m

它适用于

git comment 'Export env'

但想让它在没有引号的情况下工作

[alias]
    comment = !"git commit -m ${*}"

这会遇到错误

$ git comment Export env
error: pathspec 'env' did not match any file(s) known to git
error: pathspec 'Export' did not match any file(s) known to git
error: pathspec 'env' did not match any file(s) known to git
git git-config
1个回答
0
投票

您可以调用 shell。例如:

[alias]
        comment = !bash -c 'git commit -m \"$*\"' _
© www.soinside.com 2019 - 2024. All rights reserved.