【问题标题】:git command works in console but not as aliasgit 命令在控制台中工作,但不能作为别名
【发布时间】:2016-06-15 20:52:50
【问题描述】:

以下命令在控制台中起作用:

 git reset --soft `git rev-parse --abbrev-ref --symbolic-full-name @{u}` && git commit --edit -m "$(git log --format=%B --reverse HEAD..HEAD@{1})"

它旨在将未推送的提交压缩为一个并提供编辑消息的机会。有关详细信息,请参阅 Find out which remote branch a local branch is trackingSquash my last X commits together using Git

但是以下别名失败:

squash-uncomited = reset --soft `git rev-parse --abbrev-ref --symbolic-full-name @{u}` && git commit --edit -m "$(git log --format=%B --reverse HEAD..HEAD@{1})"

✗ git squash-uncommitted error: unknown option `abbrev-ref'

用法:git reset [--mixed | --软 | --硬 | --合并 | --keep] [-q] []

或:git reset [-q] [--] ... 或:git reset --patch [] [--] [...]

为什么会这样?别名和 CLI 命令有什么区别?

【问题讨论】:

    标签: git bash


    【解决方案1】:

    那里有一个完整的管道,而不仅仅是一个 arglist 重写。将!git放在它前面,让git再次通过shell运行整个东西,第一个命令为git reset

    【讨论】:

    • 这似乎适用于第一部分,但它失败了“错误:开关‘m’需要一个值”
    • 在双引号前面加上反斜杠。
    猜你喜欢
    • 1970-01-01
    • 2019-02-11
    • 2018-06-28
    • 1970-01-01
    • 2019-01-22
    • 1970-01-01
    • 2022-06-14
    • 2023-03-06
    • 1970-01-01
    相关资源
    最近更新 更多