繁体   English   中英

用于添加/提交/推送多个输入的 Git 别名命令

[英]Git alias command for add/commit/push with multiple inputs

我想要一个别名,让你添加一个文件,提交和推送它。

我从这个开始:

[alias]
    acp = "!f() { git add $1; }; f"

但是每当我输入时,我都会收到一个找不到文件的错误:

fatal: pathspec 'test.txt' did not match any files

理想情况下,我希望能够写:

git acp 'myfile.txt' 'my commit message'

我有这个工作,但我不能让它与添加输入一起工作:

acp2 = "!f() { git add --all; git commit -m \"${1:-commit}\"; git push origin master; }; f"
[alias]
acp = "!f() { git add \"$1\"; git commit -m \"${2:-commit}\"; git push origin master; }; f"

这应该足以处理您的语法:

git acp 'myfile.txt' 'my commit message'

我对此进行了如下测试:

$ echo>test
$ git acp test "the message"
[master 9b81eb2] the message
 1 file changed, 1 insertion(+)
 create mode 100644 test

$ cat .git/config
...
[alias]
    acp = "!f() { git add \"$1\"; git commit -m \"${2:-commit}\"; }; f"
$

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM