git别名可以在其名称中包含句点(.)吗?

Ase*_*ore 4 git alias

我发现自己经常打字git st .(st已经别名的地方status)来获取当前目录文件的状态.

我经常错误地认为那git st.当然不被认可.

我希望能够使用别名,st.但似乎不能.如果我添加st. = status .到我的.gitconfig别名,我fatal: bad config file在git调用上会出错.

是否可以创建一个包含句点的别名?

Gre*_*ill 7

不,这是不可能的(没有改变和重新编译Git本身).从git-config文档:

变量名称不区分大小写,仅允许使用字母数字字符-,并且必须以字母字符开头.


Von*_*onC 5

没有; 如果你看config.c,它必须是字母数字.

/*
 * Validate the key and while at it, lower case it for matching.
 */
*store_key = xmalloc(strlen(key) + 1);

dot = 0;
for (i = 0; key[i]; i++) {
    unsigned char c = key[i];
    if (c == '.')
        dot = 1;
    /* Leave the extended basename untouched.. */
    if (!dot || i > baselen) {
        if (!iskeychar(c) ||
            (i == baselen + 1 && !isalpha(c))) {
            error("invalid key: %s", key);
            goto out_free_ret_1;
        }
        c = tolower(c);
    } else if (c == '\n') {
        error("invalid key (newline): %s", key);
        goto out_free_ret_1;
    }
    (*store_key)[i] = c;
}
(*store_key)[i] = 0;
Run Code Online (Sandbox Code Playgroud)