Py学习  »  Git

如何将除前两个参数外的所有bash参数设置为git alias

Joao Albuquerque • 5 年前 • 1355 次点击  

我想创建一个git别名,它将使用我定义的模板创建一个提交消息。

“[$firstVariable]$secondVariable:$thirdVariable”

  1. 分支机构编号 ,
  2. 提交类型
  3. 最后一个论点是 提交消息的主题

示例:

“[1000]专长:添加新的销售控制器”

这是我的bash函数 .gitconfig 文件:

[alias]
    c = "!f() { branchNumber=${1}; type=${2}; shift; shift; subject=${*}; git commit -m '['"$branchNumber"'] '"$type"': '"$subject"' '; }; f"

如果我执行这个命令,我会得到:

命令: $ git c 1000 feat add new sales controller

返回:

错误:pathspec'sales'与git已知的任何文件都不匹配。


观察:

  • 如果我在 $subject

新销售总监

错误:pathspec'controller'与git已知的任何文件都不匹配。

  • 如果我在 $主题 别名正在工作
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/56753
 
1355 次点击  
文章 [ 1 ]  |  最新文章 5 年前