Git 带有可选文本的快速提交的别名
Git alias for fast commit with optional text
这是我在CONFIG文件中的git别名配置
[alias]
cm = "!git add .;git commit -m 'commit';git push origin master"
而不是对每个提交使用 'commit',我想用类似的东西来指定它:
git cm --'my commit text'
或
git cm 'commit text'
更好的是,参数应该是可选的,这样我就可以简单地键入 git cm
来提交文本 'commit',但是实际上这不是优先事项
如果你要使用位置参数,我建议使用函数:
cm = "!f() { git add .; git commit -m \"${1:-commit}\"; git push origin master; }; f"
!
指示 git 到 运行 子 shell 中的命令。定义了函数 f
,它使用作为第一个参数提供的消息或默认值 commit
。然后调用该函数。
像 git cm "your message here"
一样使用它,或者只是 git cm
使用默认值。
这是我在CONFIG文件中的git别名配置
[alias]
cm = "!git add .;git commit -m 'commit';git push origin master"
而不是对每个提交使用 'commit',我想用类似的东西来指定它:
git cm --'my commit text'
或
git cm 'commit text'
更好的是,参数应该是可选的,这样我就可以简单地键入 git cm
来提交文本 'commit',但是实际上这不是优先事项
如果你要使用位置参数,我建议使用函数:
cm = "!f() { git add .; git commit -m \"${1:-commit}\"; git push origin master; }; f"
!
指示 git 到 运行 子 shell 中的命令。定义了函数 f
,它使用作为第一个参数提供的消息或默认值 commit
。然后调用该函数。
像 git cm "your message here"
一样使用它,或者只是 git cm
使用默认值。