簡體   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