use*_*166 5 git alias git-config
我有一个像这样的gitconfig:
[alias]
l = "!source ~/.githelpers && pretty_git_log"
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我得到以下信息:
[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
Run Code Online (Sandbox Code Playgroud)
当我添加任何其他shell内置程序进行测试时,它们运行良好:
[alias]
l = "!echo running from the builtin"
[desktop] git l
running from the builtin
Run Code Online (Sandbox Code Playgroud)
知道为什么无法从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
Run Code Online (Sandbox Code Playgroud)
失败源于以下事实:!<command>构造试图通过该名称查找要运行的程序。有一个/bin/echo程序(与您的Shell的内置程序不同echo,但这是不同的故事),但是没有一个/bin/source(/usr/bin或任何其他地方)。从本质source上讲,它不能是单独的程序。
尝试以下方法:
[alias]
l = "!sh -c 'source ~/.githelpers && pretty_git_log'"
Run Code Online (Sandbox Code Playgroud)
根据需要更改sh为bash(或任何其他值)。
| 归档时间: |
|
| 查看次数: |
1038 次 |
| 最近记录: |