我有一个像这样的 gitconfig:
[alias]
l = "!source ~/.githelpers && pretty_git_log"
当我运行它时,我得到这个:
[desktop] git l
source ~/.githelpers && pretty_git_log: 1: source: not found
error: cannot run source ~/.githelpers && pretty_git_log: No such file or directory
fatal: While expanding alias 'l': 'source ~/.githelpers && pretty_git_log': No such file or directory
当我添加任何其他 shell 内置函数进行测试时,它们运行良好:
[alias]
l = "!echo running from the builtin"
[desktop] git l
running from the builtin
知道为什么无法从 git 找到 source 命令吗?我正在运行 zsh,但更改为 bash 似乎没有什么区别:
[desktop] bash
[desktop] git l
source ~/.githelpers && pretty_git_log: 1: source: not found
error: cannot run source ~/.githelpers && pretty_git_log: No such file or directory
fatal: While expanding alias 'l': 'source ~/.githelpers && pretty_git_log': No such file or directory
失败的原因在于!<command>
构造尝试找到一个具有该名称的程序来运行。有一个/bin/echo
程序(这与你的 shell 的内置程序不同)echo
,但那是一个不同的故事),但没有/bin/source
(or /usr/bin
或任何其他地方)。本质上是什么source
确实如此,它不能是一个单独的程序。
试试这个:
[alias]
l = "!sh -c 'source ~/.githelpers && pretty_git_log'"
Change sh
to bash
(或任何)必要时。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)