bash - Git Alias - 带有分支名称的 git commit

标签 bash git alias

我想要一个 git 别名来提交一条消息并自动填充提交消息中的分支名称。 输出示例:git commit -m "[EX-1234] This is the commit message"

我正在寻找一种仅在终端中输入的方法:git cm this is the commit message并且它将执行输出示例。

我尝试过的事情

cm = "git commit -m \'[$(current_branch)] ${1}\'"
cm = "!f() { \
         git commit -m '[$(current_branch)] $1'; \
       }; f"
cm = '!sh -c '\''git commit --m  "${1}"'\'' -'

上面的例子不起作用

最佳答案

使用 $@ 将所有参数传播到底层命令,如下所示:

cm = "!f() { git commit -m "[$(current_branch)] $@"; }; f"

关于bash - Git Alias - 带有分支名称的 git commit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56977704/

相关文章:

bash - 在 Bash 中每秒运行一次命令?

git - 为多个开发分支(和标签)并行维护多个补丁/功能分支

ubuntu - 如何为ubuntu创建一个永久的 “alias”?

c++ - map of map 的 typedef 别名

regex - 为什么 sed 不打印可选组?

java - 从 Java 程序中运行 bash 命令

bash - zsh - 找不到书面脚本的命令

混帐克隆 : no address associated with name

node.js - npm 本地依赖太多?

mysql - 具有日期类型的数据透视表